Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97808

Selenium WebDriver throwing TimoutException while invoking getScreenshotAs()

$
0
0

This is my code.

public static void test1() throws IOException {
    System.setProperty("webdriver.chrome.driver", "data/chromedriver.exe");
    drive = new ChromeDriver();
    drive.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
    try {
        drive.get("http://youtube.com");
    }catch(TimeoutException e) {
        printSS();
    }

}

public static void printSS() throws IOException{
    String path = "logs/ss/";
    File scrFile = ((TakesScreenshot)drive).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File(path + "asdasdas" + ".jpg"));
}

All time when driver.get() throw TimeoutException I want to take a screenshot at browser.

But when throw TimeoutException, getScreenshotAs() from printSS() don't take screenshot because throw another TimeoutException.

Why getScreenshotAs() throw TimeoutException and how to take screenshot at browser

P.S.: Increase pageLoadTimeout time is not the answer I want.


Viewing all articles
Browse latest Browse all 97808

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>