【问题标题】:PHPUnit Selenium2 not returning textPHPUnit Selenium2不返回文本
【发布时间】:2014-12-29 04:11:34
【问题描述】:

我正在尝试从元素中获取 text 值,并且尝试了很多变化。没有任何效果..这是我最近的尝试:

    $totalFlightPrice = $row->elements($row->using('css selector')->value('span[class="totalPriceToBook"]'));
    echo 'counted: '.count($totalFlightPrice)."\n";
    foreach ($totalFlightPrice as $tp) {
        echo 'text: '.$tp->text()."\n";
    }

当我在 totalFlightPrice 上使用 var_dump 时,我正在接收对象,这意味着它能够找到 div。 但是当我使用 text 函数时没有返回任何内容。

这是我的 span 元素:

<span class="totalPriceToBook">382€</span>

【问题讨论】:

    标签: php selenium selenium-webdriver phpunit


    【解决方案1】:

    尝试使用getText()方法http://docs.tadiavo.com/phpunit/www.phpunit.de/pocket_guide/3.1/en/selenium.html将元素的xpath作为参数。

    $this->getText("xpath=//div/span[@class='totalFlightPrice");
    

    【讨论】:

      猜你喜欢
      • 2015-02-16
      • 2015-07-01
      • 2018-05-12
      • 2012-05-24
      • 1970-01-01
      • 2014-11-16
      • 2015-11-24
      • 2012-12-13
      • 2013-06-14
      相关资源
      最近更新 更多