【问题标题】:How to get a screenshot using Selenium Webdriver? [duplicate]如何使用 Selenium Webdriver 获取屏幕截图? [复制]
【发布时间】:2019-03-11 00:17:41
【问题描述】:

我需要在我的 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"));
}}

关于步类:

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();

我该如何解决?谢谢

【问题讨论】:

    标签: java selenium webdriver screenshot


    【解决方案1】:

    您可以使用谷歌来解决此类常见问题。

    给你:https://www.guru99.com/take-screenshot-selenium-webdriver.html

    【讨论】:

      猜你喜欢
      • 2015-11-13
      • 2014-07-15
      • 2012-10-26
      • 2023-01-23
      • 2015-10-28
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      相关资源
      最近更新 更多