How to capture screenshot in selenium webdriver using java?

Published On: 5 October 2023.By .
  • General
  • Performance and Security
  • Quality Engineering

In Selenium WebDriver, capturing screenshots serves the purpose of analyzing bugs or issues that may occur during test execution. While Selenium WebDriver can automatically take screenshots during a test run, users also have the option to manually trigger screenshot capture by using the “TakeScreenshot” method. This method instructs the WebDriver to capture a screenshot and save it for further analysis within the Selenium framework.

Code implementation:-

Note:- After execution of the code, you will get the screenshot with the name(fullscreenshot.png or partialscreenshot.png) in your system at the location given in ‘srcfilepath’.

Related content

That’s all for this blog