35# How to capture individual Webelement screenshots in Selenium

Опубликовано: 04 Ноябрь 2024
на канале: Knowledge Share
244
4

In this session you will learn about how to capture individual WebElement screenshots in selenium

Please watch below video to learn how to capture webpage screenshots in selenium
   • 34# How to capture screenshots or mul...  


Github link for all the programs and techniques on Framework design pre-requisites
https://github.com/knowledgeshare-tec...

Please join Facebook Group from below link
  / 4754296501308288  

**************************************
Capture Screenshot Program
**************************************

package framework.prerequisites;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class CaptureWebElementScreenshot {

public static void main(String[] args) throws IOException
{
WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();

driver.get("http://demowebshop.tricentis.com/login");
driver.findElement(By.id("Email")).sendKeys("[email protected]");
driver.findElement(By.id("Password")).sendKeys("12345678");
driver.findElement(By.xpath("//*[@value='Log in']")).click();

WebElement email_display=driver.findElement(By.className("account"));

File scrfile=email_display.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrfile, new File("E:\\Selenium + Java - Youtube\\WebElements\\email_display.png"));

}

}

*****************************************************************************

GitHub Repository link for basic Selenium programs for practise
https://github.com/knowledgeshare-tec...

Please check below Playlist for your easy Learning

Step-by-Step Selenium Learning Playlist
   • Selenium  

Module-wise Learning Playlist for Selenium

Selenium Module - 1 Playlist
   • Selenium - Module_1  

Selenium Module - 2 Playlist
   • Selenium - Module_2  

Selenium Module - 3 Playlist
   • Selenium - Module_3  

Selenium Module - 4 Playlist
   • Selenium - Module_4  

Selenium Module - 5 Playlist
   • Selenium - Module_5  

Selenium Module - 6 Playlist
   • Selenium - Module_6  

Selenium Module - 7 Playlist
   • Selenium - Module_7  

Core Java Basic Concepts Playlist
   • Core Java  

OOPS Concepts Playlist
   • OOPS Concepts in Java