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,490 points
3,538 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

Difference between webdriver wait and fluent wait in Selenium Webdriver?

Hi Bunty, WebDriverWait is applied on certain ...READ MORE

answered Jun 12, 2019 in Selenium by Anvi
• 14,150 points
8,065 views
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,460 points
1,741 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,500 points
17,391 views
0 votes
2 answers

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,500 points
13,598 views
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

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

answered Apr 14, 2018 in Selenium by king_kenny
• 3,710 points
4,305 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,099 views
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,910 points
7,189 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
3,798 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
2,429 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP