Replace implicit wait with explicit wait (selenium webdriver & java)

前端 未结 5 1353
轮回少年
轮回少年 2020-11-22 12:37

How can I replace this implicit wait with an explicit one?

driver = new ChromeDriver(capabilities);

driver.manage().deleteAllCookies();

5条回答
  •  轮回少年
    2020-11-22 13:17

    once you declare implicitlyWait it will apply to your all element through out the script run. So declare it initially to prevent from script getting fail.

    Now if there is element which requires explicit wait then just declare it just before to do some action or use refernce of same. explicit wait is not applied through out like implicitlyWait.

    Example :-

    WebElement seleniumlink;
    seleniumlink= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='add_files_btn']")));
    seleniumlink.click();
    

    Refer below link for more details :-

    https://www.guru99.com/implicit-explicit-waits-selenium.html

提交回复
热议问题