Take screenshots
Learn how to take screenshots from within Appium tests and use them.
In cases where you would want to automatically take screenshots, be it to file a bug when an assert condition fails, or just to document how the website looks on different screens, you can take screenshots from within the tests.
You can save these screenshots to the machine that runs your automated tests. If you are on a CI/CD setup, make sure you transfer these screenshots before you wind down the machine.
Here is an example of code snippet to take a screenshot and save it to your machine :
# Import the relevant packages
# Your test code
# Take a screenshot
driver.screenshot_as(:base64) # via core_lib
@driver.screenshot_as(:base64)
# Save screenshot to /location/to/screenshot.png
/* Import the relevant packages */
/* your test code */
/* Take a screenshot */
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
/* Save screenshot to /location/to/screenshot.png */
# Import the relevant packages
# your test code
# Take a screenshot
screenshotBase64 = self.driver.get_screenshot_as_base64()
# Save screenshot to /location/to/screenshot.png
//Import the relevant packages
// your test code
// Take a screenshot
let screenshot = driver.takeScreenshot();
let screenshot = await driver.takeScreenshot();
// Save screenshot to /location/to/screenshot.png
//Import the relevant packages
// your test code
// Take a screenshot
Screenshot screenshot = driver.GetScreenshot();
// Save screenshot to /location/to/screenshot.png
//Import the relevant packages
// your test code
// Take a screenshot
// Save screenshot to /location/to/screenshot.png
Some platforms may have settings that prevent screenshots from being taken, for security reasons. One such feature is the Android FLAG_SECURE layout parameter.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!