Re: [selenium-users] Taking a screenshot is killing the browser as of late and used to work fine

33 views
Skip to first unread message

krishnan.ma...@gmail.com

unread,
Apr 30, 2015, 10:28:03 PM4/30/15
to Selenium Users

Your test is running against firefox v37 with 2.45.0 of selenium.

I woule start from this and check if both these are compatible with each other before proceeding further.  There are a lot of threads regarding how to do this (Darrell G has sent some really nice elaborate replies that you can find in this forum )

-Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else"



-------- Original Message --------
From: confusa <materia...@gmail.com>
Sent: Friday, May 1, 2015 03:15 AM
To: seleniu...@googlegroups.com
Subject: [selenium-users] Taking a screenshot is killing the browser as of late and used to work fine

Recently I have been getting lots of instances where the browser dies on screenshot creation. Stack trace:

 [testng] INFO: Taking screenshot of failed test testThis
   [testng] Exception in thread "pool-1-thread-1" org.openqa.selenium.WebDriverException: Error communicating with the remote browser. It may have died.
   [testng] Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
   [testng] System info: host: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_20'
   [testng] Driver info: driver.version: FirefoxDriver
   [testng] Command duration or timeout: 9 milliseconds
   [testng] Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
   [testng] System info: host: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64', java.version: '1.7.0_25'
   [testng] Session ID: 8c05064b-342e-4c4a-b3cd-078c8ef24598
   [testng] Driver info: net.test.framework.RemoteWebDriverCustom
   [testng] Capabilities [{platform=MAC, javascriptEnabled=true, acceptSslCerts=true, browserName=firefox, rotatable=false, locationContextEnabled=true, webdriver.remote.sessionid=8c05064b-342e-4c4a-b3cd-078c8ef24598, version=37.0.2, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, webStorageEnabled=true, nativeEvents=false, applicationCacheEnabled=true, takesScreenshot=true}]
   [testng]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   [testng]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
   [testng]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   [testng]     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
   [testng]     at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
   [testng]     at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
   [testng]     at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
   [testng]     at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
   [testng]     at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:324)
   [testng]     at net.test.framework.CustomListener.onTestFailure(CustomListener.java:159)
   [testng]     at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895)
   [testng]     at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
   [testng]     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292)
   [testng]     at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
   [testng]     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
   [testng]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   [testng]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   [testng]     at java.lang.Thread.run(Thread.java:724)

The code in question on the custom listener is:

    if (TestBase.driver != null && TestBase.driver instanceof TakesScreenshot) {
        LOGGER.log(Level.INFO, "Taking screenshot of failed test " + result.getMethod().getMethodName());
        File tempFile = ((TakesScreenshot) TestBase.driver).getScreenshotAs(OutputType.FILE);
        try {
        String fileName = String.format("temp/%s_%s.png", result.getMethod().getMethodName(), date);
        FileUtils.copyFile(tempFile, new File(fileName));
        LOGGER.log(Level.INFO, "Screenshot taken " + fileName);
        } catch (IOException e) {
        e.printStackTrace();
        }
    }

This used to work fine, but in the last month or so it crashes the browser, in this case FireFox running in remote. Driving me batty as nothing changed. Any ideas?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c791e5ff-80a4-4827-8dec-b446a5c84608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages