Created
May 30, 2019 23:59
-
-
Save mdsauce/a1794d941514e7996c7883d716bdda3f to your computer and use it in GitHub Desktop.
test fails and then kills process, stopping future commands
This file contains 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
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.by import By | |
from sauceclient import SauceClient | |
import os | |
username = os.environ.get('SAUCE_USERNAME') | |
access_key = os.environ.get('SAUCE_ACCESS_KEY') | |
sauce_client = SauceClient(username, access_key) | |
desired_caps = { | |
'platform': "Windows 7", | |
'browserName': "Firefox", | |
'version': "latest", | |
'build': "Firefox Resolution Test", | |
'name': "Resolution Test", | |
'screenResolution': "2560x1600" | |
# 'tunnelIdentifier': "myTestTunnel" | |
# 'goog:chromeOptions':{"w3c": "true"} | |
} | |
driver = webdriver.Remote(command_executor="http://%s:%[email protected]/wd/hub" % (username, access_key), desired_capabilities=desired_caps) | |
driver.maximize_window() | |
driver.execute_script("sauce:context=Now moving to Google") | |
driver.get("https://www.google.com") | |
driver.get("https://saucelabs.com") | |
wait = WebDriverWait(driver, 60) | |
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "site-container"))) | |
if driver.title != "Cross Browser Testing, Selenium Testing, Mobile Testing | Sauce Labs": | |
sauce_client.jobs.update_job(driver.session_id, passed=False) | |
driver.quit() | |
# if you remove this exit | |
# the test will Fail and close, then continue sending commands to the current driver session ID | |
exit(1) | |
driver.get("https://www.google.com/") | |
query_input = wait.until(EC.presence_of_element_located((By.NAME, "q"))) | |
sauce_client.jobs.update_job(driver.session_id, passed=True) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment