Explicit Wait and Fluent Wait error in Selenium Webdriver

0 votes

I wrote a code using Selenium in which I created a method that will explicitly wait for elements to appear
but its working as I expected. Below is the cose:

public String explicitWait(String new1) {

    WebDriverWait wait = new WebDriverWait(driver,30);
    WebElement element = wait.until(
                        ExpectedConditions.elementToBeClickable(By.id(new1)));
    return new1;
}

Then I call the method and pass it a parameter like this:

explicitWait("new-message-button");

But its not working, please help in this

Apr 2, 2018 in Selenium by Shubham
• 13,310 points
763 views

1 answer to this question.

0 votes

You should use Explicit wait or Fluent Wait for this matter. Below is the example which will help you

WebDriverWait wait = new WebDriverWait(WebDriverRefrence,20);
WebElement web1;
web_1= wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("web_1")));

Example of Fluent Wait -

Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)                           
.withTimeout(20, TimeUnit.SECONDS)         
.pollingEvery(5, TimeUnit.SECONDS)         
.ignoring(NoSuchElementException.class);    

  WebElement web1= wait.until(new Function<WebDriver, WebElement>() {      
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("web_1"));    

});

answered Apr 2, 2018 by ghost
• 1,790 points
@ghost, I agree with you. Explicit waits/Fluent waits are always recommended to be used while locating a web element.

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Implicit wait & Explicit wait in selenium WebDriver

Implicit Wait:  While loading a web page in ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,420 points
220 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,110 points
5,987 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
983 views
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

Implicit wait: Your telling the WebDriver the ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,650 points
965 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,140 views
0 votes
1 answer

Differences between Implicit wait Vs. Explicit wait in selenium webdriver

Implicit Wait - It instructs the web driver ...READ MORE

answered Apr 9, 2018 in Selenium by ghost
• 1,790 points
1,545 views
0 votes
1 answer

Handling JavaScript Alert window in Selenium WebDriver

You should try using waits for alerts ...READ MORE

answered Apr 10, 2018 in Selenium by ghost
• 1,790 points
906 views