javaseleniumselenium-webdriverphantomjsghostdriver

PhantomJSDriver take screenshot after X seconds?


I was using PhantomJSDriver to take screenshots of many urls.

The problem was that timeout occurs for some of urls. I examined those urls which have failed, and I realize those url takes long time for them to be 'fully' loaded.

I can't just extend pageLoadTimeout because it will take too much time to process all the urls. So, I would rather make PhantomJSDriver to not wait until the page is fully loaded.

Would it be possible for PhantomJSDriver to take screenshot after X seconds, whether it's fully loaded or not?

Thanks


Solution

  • You can pause the execution of the running thread for sometime after url navigation and then take the screenshot.

    driver.Navigate().GoToUrl(url);
    Thread.Sleep(1000); // 1000 milli seconds
    driver.GetScreenshot()