How to capture screen shot in Selenium

Ratings:
(4)
Views:0
Banner-Img
  • Share this blog:

 

Advantages:-

2To automate GUI test cases it is not possible to write the scripts to check the look and feel of the page .so, we can capture the screenshot and screenshot can be analyzed manually for GUI.

2If any test case fails to analyze the failed result we need to capture the screenshot.

2we can capture the screenshot in three formats.

1).png

2).jpg

3).bmp

Interested in mastering Selenium Training? Enroll now for FREE demo on Selenium Training In Pune.

** write a program to capture the screenshots for the homepage & holidays page in spicejet.com

  • How to capture a screenshot with a timestamp.

Public  void screenshots(string str) throws exception{

Date format=new simple date format(“%//,mm-dd mn-mm-ss”);

Date d=new date();

String time=date format.format(d);

System.out.print/n(eixe);

File f=((takes screen shot)driver).get screenshot as(output.file);

Check out the top Selenium Interview Questions now!

File units.copy file(f,new file(“E:\workspace-10 am \”+str+time+”.pvg”));

}

@test

Public void f() throws exception {

Screenshots(“homepage”);

Driver.findelement(by.linktest(“holidays”)).click();

Screenshot(“holidays”);

For an Indepth knowledge on Selenium, click on below

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox