Skip to content

Commit

Permalink
webui: travis selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens committed Nov 28, 2018
1 parent 17fbdd1 commit 50fc4bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -14,7 +14,6 @@ compiler:

env:
global:
- TRAVIS="yes"
# -- BEGIN Coverity Scan ENV
# The build command with all of the arguments that you would apply to a manual `cov-build`
# Usually this is the same as STANDARD_BUILD_COMMAND, excluding the automated test arguments
Expand Down
31 changes: 26 additions & 5 deletions webui/tests/selenium/webui-selenium-test.py
Expand Up @@ -16,8 +16,17 @@
from selenium.webdriver.support.ui import Select, WebDriverWait
from time import sleep

if os.environ.get('TRAVIS'):
#
# try to import the SauceClient,
# required for builds inside https://travis-ci.org,
# but not available on all platforms.
#
try:
from sauceclient import SauceClient
except ImportError:
pass



class BadJobException(Exception):
'''Raise when a started job doesn't result in ID'''
Expand Down Expand Up @@ -114,7 +123,11 @@ def __setUpTravis(self):
buildnumber = os.environ['TRAVIS_BUILD_NUMBER']
if buildnumber:
self.desired_capabilities['build'] = buildnumber
self.desired_capabilities['name'] = "Travis Build Nr. {}: {}".format(buildnumber, self.id())
# ${TRAVIS_JOB_WEB_URL}
# ${TRAVIS_BUILD_WEB_URL}
# https://github.com/bareos/bareos/tree/${TRAVIS_BRANCH}
# https://github.com/bareos/bareos/tree/${TRAVIS_COMMIT}
self.desired_capabilities['name'] = "Travis Build Nr. {}: {}".format(buildnumber, __getTestName())
self.desired_capabilities['platform'] = "macOS 10.13"
self.desired_capabilities['browserName'] = "chrome"
self.desired_capabilities['version'] = "latest"
Expand Down Expand Up @@ -437,16 +450,24 @@ def close_alert_and_get_its_text(self, accept=True):
return alert_text

def tearDown(self):
logger = logging.getLogger()
if self.travis:
print("Link to test {}: https://app.saucelabs.com/jobs/%s".format(self.id(), self.driver.session_id))
print("Link to test {}: https://app.saucelabs.com/jobs/{}".format(self.__getTestName(), self.driver.session_id))
sauce_client = SauceClient(self.sauce_username, self.access_key)
if sys.exc_info() == (None, None, None):
sauce_client.jobs.update_job(self.driver.session_id, passed=True)
else:
sauce_client.jobs.update_job(self.driver.session_id, passed=False)
self.driver.quit()
try:
self.driver.quit()
except WebDriverException as e:
logger.warn('{}: ignored'.format(str(e)))

self.assertEqual([], self.verificationErrors)

def __getTestName()
return self.id().split('.',1)[1]



def get_env():
Expand Down Expand Up @@ -482,7 +503,7 @@ def get_env():
sleeptime = os.environ.get('BAREOS_DELAY')
if sleeptime:
SeleniumTest.sleeptime = float(sleeptime)
if os.environ.get('TRAVIS') == 'yes':
if os.environ.get('TRAVIS_COMMIT'):
SeleniumTest.travis = True
SeleniumTest.sauce_username = os.environ.get('SAUCE_USERNAME')
SeleniumTest.access_key = os.environ.get('SAUCE_ACCESS_KEY')
Expand Down

0 comments on commit 50fc4bd

Please sign in to comment.