How can I take a screenshot with Selenium WebDriver?

后端 未结 30 2624
不知归路
不知归路 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:36

    C#

    public static void TakeScreenshot(IWebDriver driver, String filename)
    {
        // Take a screenshot and save it to filename
        Screenshot screenshot = ((ITakesScreenshot)driver).GetScreenshot();
        screenshot.SaveAsFile(filename, ImageFormat.Png);
    }
    

提交回复
热议问题