java - Selecting or Asserting values from search suggestions -


enter image description herei trying to perform operating selenium webdriver java below

1.open amazon site 2.type ipad in search text field -- displays few suggestions text 3.perform operation select or print number of items in suggestions

while doing this, observed html code related suggestions never showed in dom ( pure ajax response), if case how can perform operation selecting item randomly using selenium webdriver.

another point is, after typing ipad , clicking on go , again retyping ipad provide dom having html code suggestions .

but need evaluate while type first time.

please provide suggestions.attached screenshot

you can have element inspecting on it. element, click inspect in firepath, give xpath or css have made in there. though won't provide html gets hidden. in case each element has unique id attached it. elements do:

d.findelement(by.id("twotabsearchtextbox")).sendkeys("iphone"); list<webelement> lst = d.findelements(by.xpath(".//*[contains(@id,'issdiv')]")); (webelement webelement : lst) {     system.out.println(webelement.gettext()); } 

to click index do:

lst.get(4).click(); 

or based on text, can by:

list<webelement> lst = d.findelements(by.xpath(".//*[contains(@id,'issdiv')]")); (webelement webelement : lst) {     if (webelement.gettext().equalsignorecase("your item select"))         webelement.click(); } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -