graphene and screenshots on remote browsers
kgoedert Dec 6, 2013 7:43 AMHi,
When I run my tests on my local machine using my local browser, I can take screenshots using this:
WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com/"); File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
and it works. Now, when I try to run the same tests on a selenium hub I get this error:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByGraphene$$afa97690 cannot be cast to org.openqa.selenium.TakesScreenshot
I found this post http://rkchunduri.blogspot.com.br/2011/11/remotewebdriver-cannot-be-cast-to.html but with the solution presented here, if I run the tests locally I get this error
java.lang.NullPointerException at java.util.logging.Logger.log(Logger.java:644) at org.openqa.selenium.remote.RemoteWebDriver.log(RemoteWebDriver.java:607) at org.openqa.selenium.chrome.ChromeDriver$$EnhancerByGraphene$$afebd4da.log() at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:541) at org.openqa.selenium.chrome.ChromeDriver$$EnhancerByGraphene$$afebd4da.execute() at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569) at org.openqa.selenium.chrome.ChromeDriver$$EnhancerByGraphene$$afebd4da.execute() at org.openqa.selenium.chrome.ChromeDriver.getScreenshotAs(ChromeDriver.java:173) at org.openqa.selenium.chrome.ChromeDriver$$EnhancerByGraphene$$afebd4da.getScreenshotAs()
And when I run them in the selenium hub I get
Class org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler can not access a member of class org.openqa.selenium.remote.RemoteWebDriver with modifiers "protected" at org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler.invokeReal(GrapheneProxyHandler.java:135) at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler$1.invoke(GrapheneContextualHandler.java:159) at org.jboss.arquillian.graphene.enricher.StaleElementInterceptor$1.apply(StaleElementInterceptor.java:48) at org.jboss.arquillian.graphene.enricher.StaleElementInterceptor$1.apply(StaleElementInterceptor.java:44) at org.openqa.selenium.support.ui.FluentWait$1.apply(FluentWait.java:177) at org.openqa.selenium.support.ui.FluentWait$1.apply(FluentWait.java:175) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:175) at org.jboss.arquillian.graphene.wait.WebDriverWaitImpl.until(WebDriverWaitImpl.java:87) at org.jboss.arquillian.graphene.enricher.StaleElementInterceptor.intercept(StaleElementInterceptor.java:44) at org.jboss.arquillian.graphene.proxy.InvocationContextImpl.invoke(InvocationContextImpl.java:87) at org.jboss.arquillian.graphene.enricher.SearchContextInterceptor.intercept(SearchContextInterceptor.java:50) at org.jboss.arquillian.graphene.proxy.InvocationContextImpl.invoke(InvocationContextImpl.java:87) at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler$2.call(GrapheneContextualHandler.java:209) at org.jboss.arquillian.graphene.context.BrowserActions.performAction(BrowserActions.java:62) at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.invoke(GrapheneContextualHandler.java:205) at org.jboss.arquillian.graphene.proxy.GrapheneContextualHandler.intercept(GrapheneContextualHandler.java:229) at org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByGraphene$$ede7958d.execute(<generated>) at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:32) at org.openqa.selenium.remote.AddTakesScreenshot$1.invoke(AddTakesScreenshot.java:36) at org.openqa.selenium.remote.Augmenter$CompoundHandler.intercept(Augmenter.java:286) at org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByGraphene$$ede7958d$$EnhancerByCGLIB$$9380a5cc.getScreenshotAs(<generated>)
Can anybody help with this?