java - Explicit wait is not working if the element located is of 'text' -


explicit wait not working if element located of 'text'. working fine if driver performs action i.e, entering text text box or clicking webelement etc.

public boolean waitforpagetoload(string timeoutinseconds) throws screenshotexception, interruptedexception {     boolean bflag = false;     webelement element;     boolean bstatus = true;     int timeinseconds1 = integer.parseint(timeoutinseconds);      try {         webdriverwait wait = new webdriverwait(webdriver, timeinseconds1);         while(timeinseconds1 > 0) {             element = wait.until(expectedconditions.visibilityofelementlocated(by.id("mydynamicelement")));             log.info("element status @ runtime -->"+element.isdisplayed());             if(!element.isdisplayed()) {                 timeinseconds1 = timeinseconds1 - 500;                 thread.sleep(1000);             }             else {                 system.out.println("working");                 bflag = bstatus;                 log.info("element status: - >"+bflag);                 break;             }         }     }     catch (exception e) {         screenshot.screenshot(e);     }      return bflag; } 

the above code doesnt work if locator of text i.e, if want check whether 'title' of question in stackoverflow visible or not within 40seconds.driver wait 40seconds though title appears less that. but, works fine if locator title text box. please let me know how resolve this.

you using wait quite differently supposed used.

try {     webdriverwait wait = new webdriverwait(webdriver, timeinseconds1);     element = wait.until(expectedconditions.visibilityofelementlocated(by.id("mydynamicelement"))); } catch (timeoutexception toe) {   //handle page not loading } //from on continue code synchronous knowing page loaded 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -