selenium - Checking dropdown option is selected or not using elementToBeSelected / elementSelectionStateToBe. -
i want check whether option in dropdown selected or not. webdriver should wait until value selected , after perform next operation. tried use elementtobeselected / elementselectionstatetobe not make it. how use this?
using webdriverwait expectedcondition "elementtobeselected" should want (it calls elementselectionstatetobe parameter true). if doesn't work you, check passing argument indeed webelement of option want have selected.
the code follows:
webelement option = driver.findelement(by.xpath("path/to/your/option[2]")); new webdriverwait(driver, 10) .until(expectedconditions.elementtobeselected(option)); another option creating own condition anonymous class, can example equality of values.
final select select = new select(driver.findelement(by.xpath("path/to/your/select")); new webdriverwait(driver, 10) .until(new expectedcondition<boolean>() { @override public boolean apply(webdriver driver) { // actual selected option , compare value expected value return select.getfirstselectedoption().getattribute("value").equals(expectedvalue); } });
Comments
Post a Comment