public WebElement waitForWebElement ( final By by , int minimumNumberOfMatches , int timeout , boolean scroll ) { final long endTime = SystemClock . uptimeMillis ( ) + timeout ; while ( true ) { final boolean timedOut = SystemClock . uptimeMillis ( ) > endTime ; if ( timedOut ) { searcher . logMatchesFound ( by . getValue ( ) ) ; return null ; } sleeper . sleep ( ) ; WebElement webElementToReturn = searcher . searchForWebElement ( by , minimumNumberOfMatches ) ; if ( webElementToReturn != null ) return webElementToReturn ; if ( scroll ) { scroller . scrollDown ( ) ; } } }
Waits for a web element .