In order to capture a screenshot in Selenium, one has to utilize the method TakesScreenshot. This notifies WebDrive that it should take a screenshot in Selenium and store it.
File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String screenshotBase64 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
Depending on the browser being used, the TakesScreenshot method can return the following:
- The entire page
- The current open window
- The visible segment of the current frame
- The whole display containing the browser
- The complete content of the HTML element. This essentially refers to the visible portion of the HTML element.