Rayrun
← Back to videos

How To Take Screenshot | Playwright - Part 13

Let's learn how to take a screenshot using playwright

In this video blog post, the content focuses on how to take screenshots using Selenium WebDriver in JavaScript. The presenter, Kaushik, demonstrates the code and explains the options available for taking screenshots.

The video begins by introducing the code snippet required to take a screenshot. The code is simple, with a command to take a screenshot and a path specified for saving it. Kaushik mentions that there are additional options available, such as taking a full-page screenshot or an element-level screenshot.

Next, Kaushik demonstrates the code implementation in Visual Studio Code by adding a screenshot command after each test. He also shows how to dynamically name the screenshot files by adding the date to the filename.

Kaushik then runs the code and shows the output, revealing the screenshots saved in the project directory. He mentions that the screenshots show the visible portion of the page, but he clarifies that a full-page screenshot is also possible.

To demonstrate taking a full-page screenshot, Kaushik modifies the code by adding an option for a full-page screenshot and adjusting the path. He reruns the code and shows the resulting full-page screenshot in the output.

Additionally, Kaushik shows how to take an element-level screenshot by locating a specific element on a web page using CSS selectors. He adds a command to take a screenshot of the element and specifies the path. After running the code, he displays the resulting screenshot, which captures only the specified element.

Towards the end of the video, Kaushik briefly mentions other available options for taking screenshots, such as cropping, setting image quality, and selecting image file types. He also mentions the possibility of storing the screenshot as a buffer for use in HTML files.

In conclusion, this video blog post provides a comprehensive guide to taking screenshots using Selenium WebDriver in JavaScript. Kaushik explains the code and demonstrates various options, allowing viewers to implement this functionality in their own automation projects.

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Getting Started with Playwright and VS Code
Getting Started with Playwright and VS Code
Working with multiple elements in Playwright Test (NodeJS)
Working with multiple elements in Playwright Test (NodeJS)
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.