问题描述
我正在尝试从元素中获取text
值,并且尝试了很多变化.没有任何效果..这是我最近的尝试:
I am trying to get the text
value from an element and I tried lots of variation. nothing worked.. this is my latest attempt:
$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时,我正在接收Object,这意味着它能够找到div.但是当我使用text函数时,什么也不会返回.
when I'm using var_dump on totalFlightPrice I am receving the Object, which means its able to find the div.but when im using the text function nothing is returned.
这是我的span元素:
this is my span element:
<span class="totalPriceToBook">382€</span>
推荐答案
尝试使用getText()方法 http://docs.tadiavo.com/phpunit/www.phpunit.de/pocket_guide/3.1/en/selenium.html 将元素的xpath作为参数.
Try using getText() method http://docs.tadiavo.com/phpunit/www.phpunit.de/pocket_guide/3.1/en/selenium.html takes xpath of an element as a parameter.
$this->getText("xpath=//div/span[@class='totalFlightPrice");
这篇关于PHPUnit Selenium2不返回文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!