java - WebDriver wait, different wait conditions -


i using webdriver java binding. using generic methods element waiting. 1 of them called waitbypagetitle.

here definition method:

public void waitbypagetitle(webdriver driver, string pagetitle) {         webdriverwait wait = new webdriverwait(driver, default_implicit_wait);         try {             wait.until(expectedconditions.titlecontains(pagetitle));         } catch (timeoutexception e) {             ...         }     } 

in page objects, when method needs wait page title, pass arguments method. there scenarios page title can different based on different events. how change generic waitbypagetitle method accepts multiple arguments, , can wait 1 of them ever sees first?

thanks.

you can use fluentwait , java varargs

 // method accept number of titles  public void waituntiltextchanges(webdriver driver, string... titles) {           new fluentwait<webdriver>(driver)         .withtimeout(60, timeunit.seconds)         .pollingevery(10, timeunit.milliseconds)         .until(new predicate<webdriver>() {              public boolean apply(webdriver d) {                 boolean titlematched = false;                 // current window title                 string windowtitle = driver.gettitle();                 for(string title : titles){                    // iterate through input titles , compare window title                     titlematched = windowtitle.equalsignorecase(title);                    // if match found, exit                     if(titlematched){                       break;                    }                 }                     return titlematched;             }         });     } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -