Skip to content

Instantly share code, notes, and snippets.

@DazWorrall
Created September 25, 2012 15:58
Show Gist options
  • Save DazWorrall/3782753 to your computer and use it in GitHub Desktop.
Save DazWorrall/3782753 to your computer and use it in GitHub Desktop.
Taking a screenshot using selenium
Connecting
Traceback (most recent call last):
File "screenshot.py", line 16, in <module>
desired_capabilities=desired_capabilities,
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 63, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 105, in start_session
'desiredCapabilities': desired_capabilities,
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in execute
self.error_handler.check_response(response)
File "/Users/daz/.virtualenvs/1a5c5f7263517393/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 125, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: 'The requested combination of browser, version and OS is currently unsupported in this version of Selenium (Webdriver): "safari " on "Mac 10.6"'
#!/usr/bin/env python
from selenium import webdriver
import sys
url = sys.argv[1] # http://<user>:<apikey>@ondemand.saucelabs.com:80/wd/hub
desired_capabilities={
'browserName': 'safari',
'javascriptEnabled': True,
'platform': 'MAC',
'max-duration': 90,
}
print 'Connecting'
driver = webdriver.Remote(
command_executor=url,
desired_capabilities=desired_capabilities,
)
print 'Navigating'
driver.get('http://www.google.com')
print 'Taking screenshot'
driver.get_screenshot_as_base64()
print 'Quitting'
driver.quit()
print 'Done.'
Connecting
Navigating
Taking screenshot
Traceback (most recent call last):
File "./test.py", line 21, in <module>
driver.get_screenshot_as_base64()
File "/Users/daz/.virtualenvs/1368fa811d6ec01d/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 720, in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
File "/Users/daz/.virtualenvs/1368fa811d6ec01d/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in execute
self.error_handler.check_response(response)
File "/Users/daz/.virtualenvs/1368fa811d6ec01d/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 147, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u'ERROR Selenium Server in Sauce Labs was already shut down'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment