testing - Selenium: Select value from a drop down which is dependent on value selected in another drop down -


selenium: have select value drop down dependent on value selected in drop down.

ex: have 2 drop downs 1 , 2. value populated in 2 dependent on 1. when select value in dropdown 1 page gets refreshed , value in 2 populated. have select value in drop down 2.

i receive error element no longer attached dom.

i tried using wait.until((expectedcondition<boolean>) new expectedcondition<boolean>() not me. same issue occurs.

i tried using webelement , select neither helped. can me figure out solution?

javascriptexecutor executor2 = (javascriptexecutor)driver; executor2.executescript("arguments[0].click();", <elementname>); waitfor(3000);  select <objectname1>= new select(driver.findelement(by.id("<id_for_drop_down_1>"))); selectcourse.selectbyvisibletext("<valuetobeselected>"); waitfor(2000);  select <objectname2>= new select(driver.findelement(by.id("id_for_drop_down_2"))); selectcourse.selectbyvisibletext("<valuetobeselected>"); waitfor(2000); 

i using waitfor(2000) defined function waiting specified timeperiod.

these functions need. test cases not fail due page changing during testing. such population of select tag.

public void selectbyvalue(final by, final string value){     act(by, 3, new callable<boolean>() {       public boolean call() {         boolean found = boolean.false;          wait.until(expectedconditions.refreshed(expectedconditions.elementtobeclickable(by)));          select select = new select(driver.findelement(by));          select.selectbyvalue(value);         found = boolean.true; // found          return found;       }     });   }  private void act(by by, int trylimit, boolean mode, callable<boolean> method){      boolean unfound = true;     int tries = 0;     while ( unfound && tries < trylimit ) {       tries += 1;       try {         wait.until(expectedconditions.refreshed(expectedconditions.visibilityofelementlocated(by)));         unfound = !method.call(); // found it, negated since feel more intuitive if call method returns true success       } catch ( staleelementreferenceexception ser ) {         logger.error( "error: stale element exception. ");         unfound = true;       } catch ( nosuchelementexception nse ) {         logger.error( "error: no such element exception. \nerror: "+nse );         unfound = true;       } catch ( exception e ) {         logger.error( e.getmessage() );       }     }      if(unfound)       assert.asserttrue(false,"failed locate element");   } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -