Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Taking screenshots with remote webdriver using the Python bindings
import selenium.webdriver as webdriver
import sys
def visit_page_and_take_screenshot(server, browser, url, filename):
remote = 'http://' + server + ':4444/wd/hub'
caps = { "browserName": browser }
driver = webdriver.Remote(command_executor=remote, desired_capabilities=caps, browser_profile=None)
driver.get(url)
driver.get_screenshot_as_file(filename)
driver.quit()
#TODO: Use optparse
if len(sys.argv) < 5:
print "usage: " + sys.argv[0] + " <server> <browser> <url> <filename>"
else:
visit_page_and_take_screenshot(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment