Getting Selenium to pause for X seconds

后端 未结 6 2088
小蘑菇
小蘑菇 2020-12-06 16:24

What I am trying to accomplish is browsing to a page, waiting for something to load and then taking and saving a screenshot.

The code I already have is



        
6条回答
  •  被撕碎了的回忆
    2020-12-06 16:46

    If you want to delay a certain number of seconds, rather than to respond as soon as possible, here is a function for pause similar to what selenium IDE offers:

    public void pause(Integer milliseconds){
        try {
            TimeUnit.MILLISECONDS.sleep(milliseconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    

    source

提交回复
热议问题