我正在尝试使用Grid和RemoteWebDriver从Safari获取屏幕截图。我尝试了以下几种方法:
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
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
I tried sending the key sequence that takes screen shots in MAC (command+shift+3) using
sendKeys(Keys.chord(Keys.COMMAND, Keys.SHIFT, "3"))
butKeys.COMMAND
is not considered as modifier key so this also didn't work.
此外,我还看到了这个修订版本,它应该可以解决这个问题,但是我不知道如何实施:http://code.google.com/p/selenium/source/detail?r=17731。
如果能得到帮助,我会非常感激。我正在使用MAC、Safari 5.1.7和selenium 2.25。