java如何使用SeleniumWebDriver获取屏幕截图?
我需要在selenium Webdriver代码上一步一步地获取屏幕截图,但是当我插入getscreenshot代码时,我的测试就停止了
代码:
public class Rule {
protected static WebDriver driver;
public void getscreenshot(String folder, String file) throws Exception {
File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File("Evidencias\\"+folder+"\\"+file+".png"));
}}
关于Step类:
public class Steps extends Execute {
@Given("acessei a url do portal")
public void AcessoUrl() {
Execute Executar = new Execute();
Executar.abrirBrowser();
}
@And("cliquei no botao de Login com email")
public void Login() throws Exception {
Execute Executar = new Execute();
getscreenshot("Login","01 - Acessando URL");
Executar.Login();
我怎样才能修好它?谢谢
# 1 楼答案
你可以用谷歌来回答这些常见的问题
给你:https://www.guru99.com/take-screenshot-selenium-webdriver.html