How can I take a screenshot with Selenium WebDriver?

后端 未结 30 2629
不知归路
不知归路 2020-11-21 07:48

Is it possible to take a screenshot using Selenium WebDriver?

(Note: Not Selenium Remote Control)

30条回答
  •  伪装坚强ぢ
    2020-11-21 08:40

    Java

    String yourfilepath = "E:\\username\\Selenium_Workspace\\foldername";
    
    // Take a snapshort
    File snapshort_file = ((TakesScreenshot) mWebDriver)
            .getScreenshotAs(OutputType.FILE);
    // Copy the file into folder
    
    FileUtils.copyFile(snapshort_file, new File(yourfilepath));
    

提交回复
热议问题