The nicest thing about using the built-in screen capture is that Robot will capture the visible screen. The built-in screen capture will capture the entire window in the browser, including the parts not visible, i.e. things you have to scroll to see.
Shortly after this someone asked of RemoteWebDriver supported screen capture. This was very important because Robot would not capture even the visible part of a REMOTE screen.
A quick check of RemoteWebDriver.java showed that it did NOT implement TakesScreenshot.
Recently however I found a solution. Assuming you have the code:
You can change the driver to:DesiredCapabilities dc = DesiredCapabilities.firefox(); URL url = new URL("http://localhost:4444/wd/hub"); WebDriver driver = new RemoteWebDriver(url,dc);
Now it has the capability to take a screen shot. To make the call, here are the three different outputs:WebDriver driver = new Augmenter().augment(new RemoteWebDriver(url,dc));
File f = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); String s = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64); byte[] b = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES);
And that is all there is to taking a screenshot with RemoteWebDriver. I have tried this with Firefox and InternetExplorer. I assume it works with the other browsers but I leave that for you to explore.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.