Last active
February 17, 2017 21:32
-
-
Save halkeye/c304b10fcf5808322fd05338fbffc417 to your computer and use it in GitHub Desktop.
Simple simple selenium script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import json | |
import os | |
from requests.auth import HTTPBasicAuth | |
browsers = json.loads(os.environ['SAUCE_ONDEMAND_BROWSERS'] or '[{ "browser": "firefox", "platform":"MAC", "browser-version": "latest" }]' ) | |
auth=HTTPBasicAuth(os.environ['SAUCE_USER_NAME'], os.environ['SAUCE_ACCESS_KEY']); | |
for browser in browsers: | |
print "STARTING BROWSER - %s" % browser | |
r = requests.post("https://ondemand.saucelabs.com/wd/hub/session", auth = auth, data = json.dumps({ | |
'desiredCapabilities': { | |
'browserName': browser['browser'], | |
'platform': browser['platform'], | |
'version': browser['browser-version'] | |
} | |
})) | |
if r.status_code != 200: | |
raise Exception(r.text) | |
sessionId = r.json().get('sessionId') | |
requests.delete("https://ondemand.saucelabs.com/wd/hub/session/%s/window" % sessionId, auth = auth) | |
print "SauceOnDemandSessionID=%s" % sessionId | |
print "FINISHED" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment