Closed GoogleCodeExporter closed 9 years ago
Please note that using getText() method in foreach loop invokes remote method
in selenium server which is very bad idea. For a combobox with more than 100
option items it can take a few seconds.
I recommend to select option element using xpath.
You have 2 useful methods in WebElement class:
/**
* find OPTION by text in combobox
*
*/
public function findOptionElementByText($text) {
$option = $this->findElementBy(LocatorStrategy::xpath, 'option[normalize-space(text())="'.$text.'"]');
return $option;
}
/**
* find OPTION by value in combobox
*
*/
public function findOptionElementByValue($val) {
$option = $this->findElementBy(LocatorStrategy::xpath, 'option[@value="'.$val.'"]');
return $option;
}
in CWebDriverTestCase.php you have method doing everything:
public function select( $select_id, $option_text ) {
$element = $this->getElement( LocatorStrategy::id, $select_id );
$option = $element->findOptionElementByText( $option_text );
$option->click();
}
Original comment by lukasz.k...@gmail.com
on 1 Sep 2011 at 3:08
Original comment by lukasz.k...@gmail.com
on 1 Sep 2011 at 3:12
Original comment by lukasz.k...@gmail.com
on 1 Sep 2011 at 3:12
Original issue reported on code.google.com by
selfte...@gmail.com
on 25 Aug 2011 at 12:09