I want to design a WPF page where we can capture web screen elements. This should work something similar to IE F12(DOM Explorer) select element option. Can anybody please suggest where to start. Thanks in advance
Asked
Active
Viewed 225 times
1
-
you can use selenium for that purpose – Leon Barkan May 22 '18 at 07:14
-
Thanks Leon but i want to build this feature in my project @Leon Barken – May 22 '18 at 07:16
1 Answers
0
you can use selenium for that, after the installation you can achieve it by:
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.id("hplogo"));
// Get entire page screenshot
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
BufferedImage fullImg = ImageIO.read(screenshot);
// Get the location of element on the page
Point point = element.getLocation();
// Get width and height of the element
int eleWidth = element.getSize().getWidth();
int eleHeight = element.getSize().getHeight();
// Crop the entire page screenshot to get only element screenshot
BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(),
eleWidth, eleHeight);
ImageIO.write(eleScreenshot, "png", screenshot);
// Copy the element screenshot to disk
File screenshotLocation = new File(@"C:\GoogleLogo.png");
FileUtils.copyFile(screenshot, screenshotLocation);

Leon Barkan
- 2,676
- 2
- 19
- 43
-
I do not want to use any other tools here. i want to build this feature in my project using mshtml and Internet Controls@Leon Barken – May 22 '18 at 07:22
-
try that link: https://stackoverflow.com/questions/14167621/get-a-screenshot-of-the-web-browser-control – Leon Barkan May 22 '18 at 07:30