xpath 2.0 - how to select an element in the list of elements using selenium? -
i click on drop down list button.then coming mentioned picture. have click on item1. after have select xyz. way should follow?
you can many ways.
by using getfirstselectedoption()
can select first element , using selectbyvisibletext("xyz")
selenium click on xyz thing dom must contain select attribute dropdown there many other ways create dropdown option in html
select dropdown = new select(driver.findelement(by.xpath("//img[@id='ext-gen7']"))); dropdown.getfirstselectedoption(); dropdown.selectbyvisibletext("xyz");
now if dom not using select creating dropdown can use .click()
method directly. find elements , click on location directly using .click()
. work many times.
list<webelement> examples = driver.findelements(by.xpath("your xpath")); (webelement option: examples) { if(option.gettext().contains("item2") ) option.click(); else{ syso("i not want click") } }
make sure above xpath should return value of dropdown
hope :)
please accept answer if helps ;)
Comments
Post a Comment