title: How to use WebDriverWait.until without a By locator?
body: <p>I am using Selenium WebDriver implemented with a framework (Cucumber) and I am facing an issue on waiting an element to be loaded before performing an action on it.</p>
  
  <p>Initially, I wanted to use implicit waits, but if an element is not immediately loaded, it would wait for the timeout. As it is often the case, it makes my tests longer than I would like to.</p>
  
  <p>Then, I want to use the Explicit wait to make the wait as short as possible for each cases. 
  Issue is that most on ExpectedConditions in a WebDriverWait.until are looking for elements located by a <a href="https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html" rel="nofollow">By</a> locator (which are ClassName, CssSelector, Id, LinkText, Name, PartialLinkText, Tagname or XPath). 
  I am using the WebDriverWait.until in a general function used to click on a webelement. 
  Webelements on the website I am testing are generated by dojo and don't have a static id. They don't always have other kind of by locator or they are not static.
  Developers then added an additional attribute called data-automation-id to the webelement. I would like to used this attribute in explicit wait but couldn't find a way to do it.</p>
  
  <p>I tried to use the xpath using the following code :</p>
  
  <pre><code>public void clickOnDataAutomationId(String dataautomationid) {
      WebDriverWait wait = new WebDriverWait(driver, 10);
      WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//" + findDataAutomationId(dataautomationid).getAttribute("tagName") + "[contains(@data-automation-id, '" + dataautomationid + "')]")));
      findDataAutomationId(dataautomationid).click();
  }
  </code></pre>
  
  <p>findDataAutomationId() is a function returning the first webelement containing the data-automation-id as a FluentWebElement.</p>
  
  <p>Issue is that the findDataAutomationId fails if the webelement is not immediately loaded, which makes the WebDriverWait.until meaningless. Do you see another way to workaround the By Locators without refactoring the website?</p>