How to check that a value is set on a dropdown box selenium java -
i have html code. thing option names contain lots of spaces until tags closed.
<select name="auth" id="auth" size=1 onchange="updatepagestate()"> <option value="0">open system </option> <option value="1">wep </option> <option value="2">wpa </option> <option value="3">wpa2 </option>
i want check option selected in dropdown box using selenium in java. code:
try { webdriverwait wait = new webdriverwait(driver, 20); wait.until(expectedconditions.texttobepresentinelementvalue(((by.xpath("//select [@id='auth']/option['" + authen + "']"))), authen)); system.out.println("authentification correct"); } catch (exception x) { system.out.println("authentification incorrect"); x.printstacktrace(); }
where "authen" variable read file corresponds options in dropdown box.
i following error message:
org.openqa.selenium.timeoutexception: timed out after 20 seconds waiting text ('wpa2') value of element located by.xpath: //select [@id='auth']/option['wpa2']
any on how check if string contains partial text? cannot use method .contains because it's of type boolean , .texttobepresentinelementvalue needs have second attribute type string.
maybe easier select webelement less complex @findby expression , wrap element in select provides method first selected option. can comparison.
take at:
https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/ui/select.html
Comments
Post a Comment