简体   繁体   English

拍摄Element Screenshot @ Selenium 3

[英]Take Element Screenshot @ Selenium 3

Here is written that a WebDriver should be able to take a screenshot of an element: 此处写道,WebDriver应该能够拍摄元素的屏幕截图:

http://www.w3.org/TR/webdriver/#take-element-screenshot http://www.w3.org/TR/webdriver/#take-element-screenshot

(if your screen doesn't scroll down - please go down on the left panel to "19.2 Take Element Screenshot"). (如果您的屏幕没有向下滚动-请在左侧面板上向下滚动至“ 19.2拍摄元素屏幕截图”)。

Does someone know how do code it in Java / Selenium please? 有人知道如何用Java / Selenium编写代码吗?

For elements, I think you can adapt the C# solution 对于元素,我认为您可以适应C#解决方案

How can I get screenshot of specified element using WebDriver in C# 如何在C#中使用WebDriver获取指定元素的屏幕截图

otherwise for screens: 否则用于屏幕:

With getScreenshotAs 使用getScreenshotAs

File sourcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(sourcFile, new File("/var/my_screen.jpg"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM