code: 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();
  			}
  		}
  	}
docs: Waits for a web element.
  
  @param by the By object. Examples are By.id("id") and By.name("name")
  @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches
  @param timeout the the amount of time in milliseconds to wait
  @param scroll {@code true} if scrolling should be performed