Selenium Tips: Capturing A Larger Screen Area
Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to execution in minutes.
|
x
Capturing screenshots of your exam is one of the most crucial features you can afford to an automation engineer. It & # x27; s the easiest way to actually understand from a report, why a tryout failed and how to reproduce it. While ourLive Testingwill generate picture of the entire test by nonpayment, sometimes you just want a screenshot. Selenium endorse capturing screenshots on removed machine, as discussed in a previous Tip of the Week. Selenium Webdriver3 only has a individual method to save the screen:
SaveScreenshot
This method shows the viewport - the part of the screen that the user can view. That means anything to the left or right, below the scrollbars, is locomote to be missing. Not alone that, but the exact size of the viewport will be a default that can change if the HTML change. That isn ’ t a huge topic, but if your goal is to take screenshots and compare them, it could be a problem.
One selection is the maximize window role,implemented in ruby herein github. That function is as simple as:
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.
driver.manage.window.maximizedriver.save_screenshot (& quot; screenshot_orig.png & quot;);
That allows screen capture more like this:

Sadly, as of publication clip, that cypher only act on FireFox. In Chrome there are two other options. You can cope the window sizing, like this:
target_size = Selenium: :WebDriver: :Dimension.new (1440, 1800) driver.manage.window.size = target_size
Or use resize_to, like so:
driver.manage.window.resize_to (800, 600);
Writing browser-specific code and guess pel sizing is far from the best practice we know and more like work-around-practice. It might work, it can get you started, and it is free. f you need more visual debugging creature, our serviceLive Testingwill capture total screen picture which will record every individual selection event without any surplus code. If you still want actual icon, persona by portion of the blind, and a workflow to review and approve or fail images when they differ, consider our partnerAppliTools, which provides a code and backend library that works seamlessly with Sauce. Thank for tuning in, and check rearward after the new yr for more Selenium Tip of The Week from! PS: You should follow us on
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free