selenium 中 aShot 和 Shutterbug 的区别

Difference between aShot and Shutterbug in selenium

我正在尝试学习使用 selenium 捕获屏幕截图。开始了解 aShot() 和 Shutterbug 类,后者是 webdriver 的第三方 Api。

有哪些主要区别和优势

提前致谢

Ashot() source

Ashot() is a third party utility supported by Selenium WebDriver to capture the screen shots. The below are the features supported by aShot() utility with repect to screenshots:

Capturing the entire page
Capture the Web Element
Prettifying the screenshot
Screenshot comparison
Several elements comparison

Our focus here is on capturing the entire page and capturing the web element screenshots.

Shutterstock source 不确定它是否是在 selenium 中捕获屏幕截图的工具

Shutterstock is an American provider of stock photography, stock footage, stock music, and editing tools;

如果你想执行一些其他的事情,如上面提到的 Capturing the entire pageScreenshot comparison 等。需要一些第三方库。 aShot就是其中之一。

除此之外,我们可以使用 Selenium 中的 TakesScreenshot 界面简单地只捕获可见部分的屏幕截图。

一枪

ashot is a 用于截屏、裁剪、美化、比较的实用程序。它可以用于以下目的:

  • 截取 WebElement 在不同平台(即桌面浏览器、iOS Simulator Mobile Safari、Android Emulator Browser)上的屏幕截图
  • 装饰屏幕截图。
  • 提供灵活的屏幕截图比较。

Maven 依赖:

<dependency>
    <groupId>ru.yandex.qatools.ashot</groupId>
    <artifactId>ashot</artifactId>
    <version>1.5.2</version>
</dependency>

您可以在以下位置找到一些详细的相关讨论:

  • How to capture screenshot of a WebElement within a webpage but not the entire screen or page through Selenium
  • How to take full page screenshot using AShot library through Selenium and Java

selenium-shutterbug

selenium-shutterbug is a utility library written in Java for making screenshots using WebDriver and further customizing, comparing and processing them with the help of Java AWT.

Maven 依赖:

<dependency>
    <groupId>com.assertthat</groupId>
    <artifactId>selenium-shutterbug</artifactId>
    <version>x.x</version>
    <exclusions>
    <exclusion>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
    </exclusion>
     </exclusions>
</dependency>

使用Gradle:

compile ('com.assertthat:selenium-shutterbug:x.x') {
    exclude group: "org.seleniumhq.selenium", name: "selenium-java"
    }

使用 SBT:

"com.assertthat" % "selenium-shutterbug" % "x.x" exclude("org.seleniumhq.selenium", "selenium-java"),

您可以在以下位置找到一些相关讨论:

  • Can the screeenshots generated by selenium-shutterbug be saved with extension as jpg instead of png?

差异

它们最大的区别在于, works only when the webpage supports


参考

How to take screenshot with Selenium WebDriver