-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
On this webpage: https://www.selenium.dev/downloads/ I am trying to capture the screenshot of an element that is an img tag.
You can inspect : img[alt='Java']
This is the img element I want to capture.:

So to capture the above element I wrote this code:
WebElement imgJava = driver.findElement(By.cssSelector("img[alt='Java']"));
Screenshot screenshotJava = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver, imgJava);
ImageIO.write(screenshotJava.getImage(), "png",new File(System.getProperty("user.dir") + "\\javaImg.png"));
But when I opened the image, it is just all white:

And if I remove the shooting shotingStrategy and just use new AShot().takeScreenshot(driver,imgJava);
It will take screenshot of whole page even though I passed a particular element:

Metadata
Metadata
Assignees
Labels
No labels