I am aware of the differences between them and how they actually behaves during execution. My Question is which one is more preferred in Automation using Selenium? I am using Selenium Webdriver with Java and Automating my Test-cases in TestNG framework.For some Browser the test fails because Webelement is not clickable so i doubt I have re-implement the wait time for such Web-elements.
Please suggest me some alternative.
Advertisement
Answer
To answer which wait to use will be very specific beacuse the answer may change depending on the Web-element you are focusing , Platform and many more. But what i can suggest you to use explicit wait in your situation as you specified that you are using multiple browsers and Web-element loading time is varying as per Browser. So the best deal is to use wait with Until. Your can set the WebDriver wait time to the maximum time you have observed so far, Because even if the webelement get click-able/visible it will not wait unnecessarily for the remaining time.
Below is the example of one how i implemented in my project.
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='login']"))).click();