java - I am getting StaleElementReferenceException after navigating to different Page and coming back -


i getting staleelementreferenceexception after navigating different page , coming back.i have tried explicit wait,re-write locator again seems not working.any highly appreciated.

    select selectelement = new select(dropdown);     list<webelement> alloptions=selectelement.getoptions();     (webelement eachelement : alloptions) {           system.out.println(eachelement.gettext());         selectelement.selectbyvisibletext(eachelement.gettext());         clickelement(selectthisoption);         enteronlinepage().dataentry;         changedistrictpage();         waitfunctions.waitforpageloaded(driver);         new select(dropdown);       //select selectelement = new select(dropdown);         alloptions=selectelement.getoptions(); } 

this correct behaviour! once navigate anywhere (forward , back) all webelements stale. have change logic of loop, this:

select selectelement = new select(dropdown); int count = selectelement.getoptions().size(); (int = 0; < count; i++) {           // must read element again every time!         select selectelement = new select(dropdown);         selectelement.selectbyindex(i);          // rest of code ... } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -