In this video we have shown how to fix below error related to implicitly wait and explicitly wait:
“Timeouts org.openqa.selenium.WebDriver.Timeouts.implicitlyWait(long time, TimeUnit unit),
@Deprecated
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.”
Or
“The constructor WebDriverWait(WebDriver, long) is deprecated
3 quick fixes available:
@ Add @SuppressWarnings ‘deprecation’ to ‘wait’
@ Add @SuppressWarnings ‘ deprecation’ to ‘main()’
Configure Problem severity”
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Program:
public class DemoDeprecatedMethod {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "path of chrome driver exe\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://programmerworld.co/");
/* Below are depracated ones in selenium 4
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 120);
*/
/* Solution
//WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(120));
Or
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(120, 1));
*/
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(120, 1));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@title='Welcome']")));
}
}