So am currently working on a project that I intend to post about soon, and ran into an issue when trying to take screenshots using RemoteWebDriver.
Turns out that RemoteWebDriver doesn’t have the capability that the other drivers have, however after a few searches I managed to find a solution and with a small tweak got it working.
So here is how you can take screenshots using RemoteWebDriver.
You need to create a class that extends RemoteWebDriver and inherits ITakeScreenshot, should look like this:
The issue I had was that the example I found by Jim Evans, must have been when RemoteWebDriver didn’t have any paramters, so had to include the URI and Capabilities.
To use this now you have to use your ScreenShotRemoteWebDriver instead of RemoteWebDriver, like so:
Then you can take a screenshot using the following code:
Note that the screenshots are saved on the machine where the test is being executed from, not the client.
There has been lots of changes in RemoteWebDriver since I wrote this original post, one of those is that screenshots are now a lot easier as per Jan Zdrahal comment below.
So you can now create an extension for IWebDriver to take a screenshot for you that will also work with RemoteWebDriver.
Then you can call the method like so.