Selenium get value of current implicit wait

前端 未结 5 1834
悲&欢浪女
悲&欢浪女 2021-01-17 15:50

I realize that Selenium has a default value for implicit waits, but how do I get this value if I change it? For example:

<         


        
5条回答
  •  庸人自扰
    2021-01-17 16:10

    This can print real timeout value (plus calculating time, usually within 100ms):

    public void getCurrentWaitTimeout() {
        long milliseconds = java.time.ZonedDateTime.now().toInstant().toEpochMilli();
        driver.findElements(By.cssSelector(".nonExistingElement"));
        milliseconds = java.time.ZonedDateTime.now().toInstant().toEpochMilli() - milliseconds;
        log.info("Current waiting timeout is {} milliseconds", milliseconds);
    }
    

    So you can always call such a method to be sure you know actual timeout, not the value you tried to set.

提交回复
热议问题