I am able to capture screen shot with EventFiringWebDriver.
Here is the test code:
EventFiringWebDriver wd = new EventFiringWebDriver(new
InternetExplorerDriver());
or
EventFiringWebDriver wd = new EventFiringWebDriver(new
FirefoxDriver());
wd.get("
http://www.google.com");
byte[] screenShotBytes = wd.getScreenshotAs(OutputType.BYTES);
I was able to reproduce the problem when make use of remote web
driver.
EventFiringWebDriver wd =
new EventFiringWebDriver(new RemoteWebDriver(new URL(
"
http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox()));
Exception in thread "main" java.lang.UnsupportedOperationException:
Underlying driver instance does not support taking screenshots
at
org.openqa.selenium.support.events.EventFiringWebDriver.getScreenshotAs(EventFiringWebDriver.java:
254)
at Test1.main(Unknown Source)
If this is the case then i am sure use the way provided in
http://blog.infostretch.com/?p=1138. Instead of RemoteWebDriver create
RemoteWebDriver implementation as discussed in blog and use it when
creating EventFiringWebDriver instance.
For example
EventFiringWebDriver wd =
new EventFiringWebDriver(new MyRemoteWebDriver(new URL(
"
http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox()));
I did test it with ISFW provided implementation and got success.
EventFiringWebDriver wd =
new EventFiringWebDriver(new IsRemoteWebDriver(new URL(
"
http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox()));
wd.get("
http://www.google.com");
// byte[] screenShotBytes = wd.getScreenshotAs(OutputType.BYTES);
// File screenShot = wd.getScreenshotAs(OutputType.FILE);
String screenShotAsString = wd.getScreenshotAs(OutputType.BASE64);
try {
System.out.println(FileUtil.saveImageFile(screenShotAsString,
"TMP", "."));
} catch (Exception e) {
e.printStackTrace();
}
On Aug 31, 4:21 pm, cjayswal <
cjays...@gmail.com> wrote:
> Checkhttp://
blog.infostretch.com/?p=1138where possible solution to