0

I am new to selenium webdriver. Can anybody help me to use the fluentwait in my script?
Here is my HTML code:

<ul id="ui-id-6" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" tabindex="0" style="display: block; width: 827px; top: 405px; left: 374px;">
abarisone
  • 3,707
  • 11
  • 35
  • 54

3 Answers3

1

Try this:

WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("ul#ui-id-6"))));
Ranjith's
  • 4,508
  • 5
  • 24
  • 40
0

By Using Fluent waits, it waits till the element is found. If the element is not found, it retries every 5 seconds, but will wait only up to a maximum of 30 seconds.

Wait wait = new FluentWait(driver)
   .withTimeout(30, SECONDS)
   .pollingEvery(5, SECONDS)
   .ignoring(NoSuchElementException.class);
Ulf Gjerdingen
  • 1,414
  • 3
  • 16
  • 20
Khushish
  • 25
  • 1
  • 5
  • Script unable to select the item from list box by using this wait statement, message "org.openqa.selenium.TimeoutException" is printed in the console – srinuvasareddy marri Jul 08 '16 at 09:31
0

Use WebDriver wait in try/catch block,

WebDriverWait wait = new WebDriverWait(driver, timeout);
    WebElement ele = null;
    try {
          ele = wait.until(ExpectedConditions
                  .presenceOfElementLocated(locator));
    } catch (Exception e) {
          throw e;
    }

also need to pass timeout in long. For more information on dealing with internally as well external wait follow this answer. :)

Community
  • 1
  • 1
Sanjay Bhimani
  • 1,593
  • 1
  • 15
  • 29