使用Grid和RemoteWebDriver无法在Safari上进行屏幕截图

3

我正在尝试使用Grid和RemoteWebDriver从Safari获取屏幕截图。我尝试了以下几种方法:

  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 sequence that takes 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.

经过一番研究,我发现了以下问题:http://code.google.com/p/selenium/issues/detail?id=4203
此外,我还看到了这个修订版本,它应该可以解决这个问题,但是我不知道如何实施:http://code.google.com/p/selenium/source/detail?r=17731
如果能得到帮助,我会非常感激。我正在使用MAC、Safari 5.1.7和selenium 2.25。
1个回答

0

供日后参考:这似乎已经在Selenium 2.26中修复了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接