Selenium-Webdriver (Java) failing to execute 'hoverover and click' function consistently -


i'm trying access screen in application, appears when mouse-hover on tab , click on 1 of options. used actions method execute using selenium. here's code:

element=driver.findelement(by.id("tab")); actions hoverover=new actions(driver); hoverover.movetoelement(element).movetoelement(driver.findelement(by.id("menu"))).click().build().perform(); 

when login application , directly call tab, i'm able access without issue. problem occurs when access tab different screen in application.

whenever access hover-over page different page in application, page loads correctly of time fails , recieve 'no such element' or 'stale element reference' error.

i'm not sure how able access tab without issue , how throwing errors. please guide me here , let me know if there else(any additional functions/or alternative actions?) can mouse-over click works time.

edit: tried using both explicit , implicit waits , thread.sleep well, in vain. in chrome(only in chrome) when manual screen refresh while tries access tab, works. when same in code [driver.navigate().refresh()], it's not working!!

the stale element exception occurring between when set element , when hoverover. selenium like:

webelement element = driver.findelement(by.id("tab")); // "element" has been set actions hoverover=new actions(driver); // between here , hoverover, "element" has changed on dom hoverover.movetoelement(element).movetoelement(     driver.findelement(by.id("menu"))).click().build().perform(); // uh-oh, what's "element?" better throw exception! 

try eliminating element= line , moving driver.findelement inside of movetoelement().

actions hoverover = new actions(driver); hoverover.movetoelement(driver.findelement(by.id("tab")))     .movetoelement(driver.findelement(by.id("menu"))).click().build().perform(); 

you try throwing in webdriverwait between hovering on tab , menu.

hoverover.movetoelement(driver.findelement(by.id("tab"))).build().perform(); new webdriverwait(driver, 10))     .until(expectedconditions.presenceofelementlocated(by.id("menu"))); hoverover.movetoelement(driver.findelement(by.id("menu"))).click().build().perform(); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -