Normally you would augment RemoteWebDriver (which was just recently discussed in a couple of threads), but I seem to recall seeing something to the effect that the Safari driver can't do screen shots yet.
Hi, I am trying to get a screenshot from Safari using Grid and RemoteWebDriver. I have tried the following approaches:
1. Using the code below. It works on all browsers except Safari. I also tried returning a BASE64 string but didn't work.
WebDriver augmentedDriver = new Augmenter().augment(driver);
File source = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(source, new File("screenshot.png"));
Exception: org.openqa.selenium.WebDriverException
2. Using WebDriverBackedSelenium. This throws exception.
a.
Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
sel.captureScreenshot(filename);
Exception: java.lang.UnsupportedOperationException: captureScreenshot
b.Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
sel.captureScreenshotToString();
Exception: java.lang.UnsupportedOperationException: WebDriver does not implement TakeScreenshot
3. I tried sending the key squence that take screen shots in MAC (command+shift+3) using sendKeys(Keys.chord(Keys.COMMAND, Keys.SHIFT, "3")) but Keys.COMMAND is not considered as modifier key so this also didn't work.
After some research I cam across these two issues below:
I also saw this revision which is suppose to fix the issue but I am not able to figure out how to implement this
I would really appreciate if I could get some help on this. I am using MAC, Safari 5.1.7 and selenium 2.25.