Improved the integration with Sauce Labs

This commit is contained in:
axl89 2016-05-25 17:11:41 +02:00
parent 5d9f7cfe66
commit 100819d9a5
1 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,7 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from sauceclient import SauceClient
from os import environ
@ -27,6 +28,7 @@ class PandoraWebDriverTestCase(TestCase):
tickets_associated = []
sauce_username = environ["SAUCE_USERNAME"]
sauce_access_key = environ["SAUCE_ACCESS_KEY"]
sauce_client = None
desired_cap = {
'tunnel-identifier': environ["TRAVIS_JOB_NUMBER"],
@ -37,8 +39,10 @@ class PandoraWebDriverTestCase(TestCase):
def setUp(self):
self.time_started = datetime.now()
#self.driver = webdriver.Firefox()
#Start VM in Sauce Labs
self.driver = webdriver.Remote(command_executor='http://'+self.sauce_username+':'+self.sauce_access_key+'@ondemand.saucelabs.com:80/wd/hub',desired_capabilities=self.desired_cap)
self.sauce_client = SauceClient(self.sauce_username, self.sauce_access_key)
self.driver.implicitly_wait(30)
self.base_url = "http://localhost/"
self.verificationErrors = []
@ -71,6 +75,10 @@ class PandoraWebDriverTestCase(TestCase):
diff = tack - self.time_started
self.time_elapsed = diff.seconds
self.driver.quit()
#Update Sauce Labs job
is_test_successful = self.verificationErrors == []
self.sauce_client.jobs.update_job(self.driver.session_id, passed=is_test_successful,tags=[environ["TRAVIS_BRANCH"],self.id()],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(self.id().split('.')[1]))
self.assertEqual([], self.verificationErrors)
super(PandoraWebDriverTestCase, self).tearDown()