问题
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";
}
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.
this is my span element:
<span class="totalPriceToBook">382€</span>
回答1:
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");
来源:https://stackoverflow.com/questions/26698409/phpunit-selenium2-not-returning-text