WebDriver - Capturing Screen shot

By Using the TakeScreenhot Interface WebDriver will Capture the webpage this will help when test run and exceptional errors during execution.
Sample Code:
 @Test
public void testScreenshot()
{
try {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\Screeshots\\Loginpage.png"));
} catch (Exception e) {
e.printStackTrace();
}
}
How It Works....

The TakesScreenshot interface provides the getScreenshotAs() method to capture
a screenshot of the page displayed in the driver instance. In the below code , we
specified OutputType.FILE as an argument to the getScreenshotAs() method,
so that it will return the captured screenshot in a file:
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

We can save the file object returned by the getScreenshotAs() method using the
copyFile() method of the FileUtils class

38 comments:

  1. Hello Vijay

    Please tell me all files that we have to import in script before run it.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  2. http://selenium-code.blogspot.in/

    ReplyDelete
  3. Thank You !! Awesome way to present your thoughts and knowledge.
    I am a beginner and I want to learn more .Keep sharing your knowledge with us.
    Selenium Interview Questions
    Selenium Tutorial
    Selenium Training in Noida

    ReplyDelete
  4. I would like to thank you for the efforts you have made in writing this article...for any information .. Selenium Online Training

    ReplyDelete
  5. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  6. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  7. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  8. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  9. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  10. I got a clear idea of capturing screenshot with Selenium Web Drivers. I have a project regarding this, it will be very helpful for me. Vijay! Really Thanks a lot for your sharing with us.
    Selenium Training in Chennai

    ReplyDelete
  11. Very informative blog and very useful article thank you for sharing with us , keep posting learn more about selenium training , selenium online training

    ReplyDelete
  12. This is very informative blog and useful article thank you for sharing with us keep posting more details aboutselenium training,selenium online training

    ReplyDelete
  13. This is very informative blog and useful article thank you for sharing with us keep posting more details aboutselenium training,selenium online training

    ReplyDelete
  14. Appium Training in chennai
    We provides Best Appium Training in Chennai with real time project assistance by our leading Appium mobile App Automation testing architect
    For Free Live Demo @ Call to 8122241286.
    Appium ,Selenium,Mobile Automation Testiing using Android and IOS
    www.thecreatingexperts.com 
    Appium training in chennai

    ReplyDelete
  15. Advanced Selenium Framework Training in Chennai by Vishwa

    Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.

    I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
    selenium training in chennai

    ReplyDelete
  16. Hey friends, it was a great experience to learn from selenium.
    Talk to eight one two two two four one two eight six
    www.thecreatingexperts.com
    selenium training in chennai

    ReplyDelete
  17. Join them for the best selenium training in Chennai and placements.
    Call them at 8122241286.
    www.thecreatingexperts.com
    selenium training in chennai

    ReplyDelete
  18. I joined with them for selenium training and it’s going on good.
    Hope I will be placed in a good company.
    They are cool team so far in chennai .
    Call them at 8122241286.
    www.thecreatingexperts.com
    selenium training in chennai

    ReplyDelete
  19. Advanced Selenium Framework Training in Chennai by Vishwa

    Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.

    I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
    selenium training in chennai

    ReplyDelete
  20. Very usefull article
    http://thecreatingexperts.com/selenium-training-in-chennai/

    ReplyDelete
  21. Thanks for sharing great information in your blog.

    Selenium training institute which provides Real Time Hands on Training…THE CREATING EXPERTS

    http://thecreatingexperts.com/selenium-training-in-chennai/


    contact-8122241286

    ReplyDelete
  22. Thanks for sharing this blog.Creating Experts provides Best training in selenium

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  23. The Creating Experts is the leading trainer in selenium so, if you are looking for one here is the link

    http://thecreatingexperts.com/selenium-in-chennai/

    contact +91-08122241286

    ReplyDelete
  24. THE CREATING EXPERTS is one of the leading training provider in SELENIUM they provide hands on training with real time scenario

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  25. The Creating Experts provides training in SELENIUM

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  26. The Creating Experts provides training in SELENIUM

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  27. The Creating Experts provides training in SELENIUM

    They provide hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  28. nice blog...Selenium training is offered by THE CREATING EXPERTS in Chennai

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  29. SELENIUM training in Chennai by TE CREATING EXPERTS ,they provide you hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  30. SELENIUM training in Chennai

    http://thecreatingexperts.com/selenium-training-in-chennai/

    SELENIUM training in Chennai by THE CREATING EXPERTS ,

    They provide you hands on training with real time scenarios

    contact 8122241286

    ReplyDelete
  31. SELENIUM training is provided by THE CREATING EXPERTS in CHENNAI

    They provide hands on training with real time scenarios and if you are looking for one take a look at the link

    http://thecreatingexperts.com/selenium-training-in-chennai/

    Contact 8122241286 for more info

    ReplyDelete
  32. Very Nice...Contains A to Z concepts...Thanks a lot.. and looking for the best selenium training in Chennai with certification from us. we have experienced selenium experts offer selenium course training with industry exposure. Check Here https://goo.gl/VRNEXv

    ReplyDelete
  33. At Coepd - (Center of Excellence for Professional Development) Manual & Selenium testing training program is designed to give participants the skills & knowledge to gain a competitive advantage in starting/enhancing a career in software testing. We provide the attendee's software testing service which is required to ensure that tested applications meet all application requirements. Participants receive up-to-date training in multiple areas in Software Testing and a thorough understanding of real-world projects.

    http://www.coepd.com/TestingTraining.aspx

    ReplyDelete
  34. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    The Best Selenium Training in Chennai Chennai | Selenium Training institutes in Chennai

    ReplyDelete
  35. The most popular destination for Hadoop Training in

    Noida
    in NOIDA is CIITNOIDA in Sector-2

    You can Master the various components of Hadoop ecosystem like Hadoop, MapReduce Architecture, Pig, Hive, HBase, Sqoop, Flume by their Senior Experts

    from Industry with good Industrial experience of handling big projects.

    You can even Get hands-on practice with live projects and ORACLE certification at CIITNOIDA.

    This Big Data Hadoop Training in Noida is best

    suited for CS & IT Engineering Students, professionals looking to gain expertise in Big Data and work for Fortune 500 Software Companies.

    Hadoop Training in Noida
    Big Data Hadoop Training in Noida

    ReplyDelete