Selenium Tips: Taking ScreenShots on the Server
Sauce AI for Test Authoring: Move from intent to executing in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to executing in minutes.
|
x
Code is wild at checking for pre-determined problems - that a calculated output lucifer an expected result. It ’ s also sooner bad at checking for unanticipated changes. One way to do this is to take a screen seizure, store it, and compare it to the current screen - a pixel-by-pixel compare. Or store the screencaptures away and hold a human review them, perhaps as thumbnails, perchance overnight. Some of our partner companies, like, provide extensions to entrance certain ingredient of the blind, but you can get started with champaign old vanilla webdriver, using the save_screenshot command. Here ’ s a working instance in ruby and python:
Python: (The entire code)
driver = webdriver.Chrome ();
directory = os.path.dirname (os.path.realpath (__file__));
specific_filename = & quot; file: // & quot; + directory + & quot; /sample.html & quot;;
driver.get (specific_filename);
driver.save_screenshot (& quot; screenshot_python.png & quot;);
waitforit = raw_input (& quot; Press ENTER to continue ... & quot;);
driver.quit ()
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
Ruby: (The full code)
driver = Selenium: :WebDriver.for: chrome
directory = File.expand_path File.dirname (__FILE__)
specific_filename = & quot; file: // & quot; + directory + & quot; /sample.html & quot;
driver.navigate.to specific_filename
# Sleep is for educational purposes only
puts (& quot; Press ENTER to preserve ... & quot;);
waitforit = gets ();
driver.save_screenshot (& quot; screenshot_orig.png & quot;);
puts driver.title
driver.quit
Feel free to take this code out for a spin, it ischecked in to GitHubas a running, work model. Fork it and promote some contributions back.
Next time we ’ ll talking about setting the windowsize to make sure the blind captures seem identical.
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