3

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

  1. 使用下面的代码。它适用于除 Safari 之外的所有浏览器。我也尝试返回一个 BASE64 字符串,但没有奏效。

    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. 使用 WebDriverBackedSelenium。这会引发异常。

    一个。

    Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
    sel.captureScreenshot(filename);
    

    Exception: java.lang.UnsupportedOperationException: captureScreenshot

    湾。

    Selenium sel = new WebDriverBackedSelenium(driver, driver.getCurrentUrl());
    sel.captureScreenshotToString();
    

    Exception: java.lang.UnsupportedOperationException: WebDriver does not implement TakeScreenshot

  3. sendKeys(Keys.chord(Keys.COMMAND, Keys.SHIFT, "3"))我尝试使用但不被视为修饰键发送在 MAC (command+shift+3) 中进行屏幕截图的键序列,Keys.COMMAND因此这也不起作用。

经过一番研究,我遇到了以下问题: 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。

4

1 回答 1

0

供将来参考:这似乎已在 Selenium 2.26中修复

于 2013-03-21T18:34:27.690 回答