I have started running Selenium tests via PhantomJS from Python. Whenever a test raises an exception I see a traceback followed by the enigmatic phrase
Screenshot: available via screen
It would be nice to be able to view such screenshots, but I have no idea where they are being saved, nor what program (or other) is intended by screen
.
(The only "screen" I am familiar with is the terminal multiplexer, which will not show screenshots)
So - what "screen" are they talking about? How do I use it to view the screenshots?
Run the program in a try block and when the error occur take the screenshot using save_screenshot
Eg :
driver = webdriver.PhantomJS()
driver.set_window_size(1920,1080)
try:
driver.get('http://whatsmyuseragent.com/')
except Exception,e:
driver.save_screenshot('screenshot.png')
driver.close()
This will give you the screenshot during that moment Image will be saved at the working of your script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With