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? image

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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -