Decreasing the speed of Selenium Webdriver

前端 未结 1 386
眼角桃花
眼角桃花 2021-01-16 20:05

I have an selenium integration test that launches browser and checks the webstore for any broken functionality. However the entire test runs too fast and finishes before I c

相关标签:
1条回答
  • 2021-01-16 20:40

    You can play with EventFiringWebDriver.

    WebDriver driver = new FirefoxDriver();
    EventFiringWebDriver slowDriver = new EventFiringWebDriver(driver); 
    slowDriver.registerListener(new ListenerThatAddsPauses(5, TimeUnit.SECONDS));
    

    You will have to write your class ListenerThatAddsPauses which will extend AbstractEventFiringListener. In ListenerThatAddsPauses you will have to override methods from parent class and for example add needed pauses. Something like:

    @Override
    public void beforeClickOn(WebElement element, WebDriver driver) {
       Thread.sleep(timeout);
    }
    

    Here is a great example

    0 讨论(0)
提交回复
热议问题