menu click not working using selenium webdriver through java -


my code below, having problems 'production plan', need able click production plan link doesn't work.

    list<webelement> ddopts = driver.findelements(by.xpath("html/body/div[4]"));     arraylist<string> links = new arraylist<string>();    for(webelement : ddopts) {     //system.out.println(we.gettext());         links.add(we.gettext());     system.out.println(links);      if(we.gettext().contains("production plan")) {        we.sendkeys("production plan");        we.click();      } 

your webelements in ddopts list aren't anchor tags divs. don't know how page look, seems might thought xpath. like:

list<webelement> ddopts = driver.findelements(by.xpath("html/body/div/a[4]")); 

or

list<webelement> ddopts = driver.findelements(by.xpath("html/body/div[4]/a")); 

or maybe if select option, use select object

select myselect = new select(driver.findelements(by.xpath("html/body/div[4]"))); myselect.selectbyvisibletext("production plan"); 

see answer of question: how select option drop-down using selenium webdriver java?


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -