eclipse - fetch all links under/in a specific class-selenium webdriver (java) -
is there way fetch links under specific class?
the thing is, ii writing test requires me click on random item/product
if create list of links through by.tagname("a")
, it'll fetch links on page. more exact, consider this website, want randomly choose pret
,summer
sale
,accessories
, bt lawn'16
, sale
, lookbook
or after clicking on summer sale
, want randomly click on 1 of products under it. idea how it?
here snippet of program :
actually using incorrect xpath
locating pret
,summer
sale
,accessories
, bt lawn'16
, sale
, lookbook
, links try below :-
list<webelement> alllinks = driver.findelements(by.cssselector("a.level0")); random random = new random(); webelement randomlink = alllinks.get(random.nextint(alllinks.size())); randomlink.click();
Comments
Post a Comment