java - sometimes move to element and click event is not working -
i new selenium web driver , stuck follows problem. have written code hover on menu , click sub menu in jsp page.in have 3 anchor tags used click , redirect page.
but problem first , last anchors working not second tag. first , last tag action can achieve. when driver moves seconds tag not respond , says exception "no such element".
how possible. don't know why doesn't move particular tag , trigger that.kindly me. in advance.
<li style="z-index:1"><a href="welcome.jsp">business</a> <ul><li><a href="chainperformance.jsp">chain performance</a> <li><a href="topxreport.jsp">top x report</a><li> <a href="chaintop.jsp">chain top</a><li></ul></li>
code mouse hover , click:
@then ("^i hover on (.+) menu , (.+) submenu$") public void mousehover(string elementname,string submenu) throws interruptedexception{ actions actions = new actions(webdriver); webelement menuhoverlink = webdriver.findelement(by.xpath("//a[text() = '" + elementname + "']")); actions.movetoelement(menuhoverlink).perform(); thread.sleep(2000); actions.movetoelement(menuhoverlink).movetoelement(webdriver.findelement(by.xpath("//a[text() = '" + submenu + "']"))); thread.sleep(2000); actions.click().perform(); system.out.println("sub menu "+submenu+" has been clicked"); }
try removing sleep statements have given.
Comments
Post a Comment