如何用Selenium WebDriver截图有人知道是否可以使用Selenium WebDriver截图吗?(注:非硒RC)
4 回答
慕容森
TA贡献1853条经验 获得超18个赞
WebDriver driver = new FirefoxDriver();driver.get(" File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhereFileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
料青山看我应如是
TA贡献1772条经验 获得超8个赞
C#
public void TakeScreenshot(){ try { Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); ss.SaveAsFile(@"D:\Screenshots\SeleniumTestingScreenshot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception e) { Console.WriteLine(e.Message); throw; }}
- 4 回答
- 0 关注
- 1140 浏览
添加回答
举报
0/150
提交
取消