PHPUnit_Selenium

如何使用Selenium WebDriver截屏

和自甴很熟 提交于 2020-02-26 00:07:01
有谁知道是否可以使用Selenium WebDriver截屏? (注:不是硒RC) #1楼 吉顿 import org.openqa.selenium.OutputType as OutputType import org.apache.commons.io.FileUtils as FileUtils import java.io.File as File import org.openqa.selenium.firefox.FirefoxDriver as FirefoxDriver self.driver = FirefoxDriver() tempfile = self.driver.getScreenshotAs(OutputType.FILE) FileUtils.copyFile(tempfile, File("C:\\screenshot.png")) #2楼 爪哇 public String captureScreen() { String path; try { WebDriver augmentedDriver = new Augmenter().augment(driver); File source = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE); path = "