From 50fc4bd42f1ff6800f72c2be1d408afbfe6c4ebb Mon Sep 17 00:00:00 2001 From: Joerg Steffens Date: Wed, 28 Nov 2018 16:10:31 +0100 Subject: [PATCH] webui: travis selenium --- .travis.yml | 1 - webui/tests/selenium/webui-selenium-test.py | 31 +++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03d36baf37a..701407dc742 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/webui/tests/selenium/webui-selenium-test.py b/webui/tests/selenium/webui-selenium-test.py index 5dcc6ee8f87..a0456d2b842 100755 --- a/webui/tests/selenium/webui-selenium-test.py +++ b/webui/tests/selenium/webui-selenium-test.py @@ -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''' @@ -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" @@ -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(): @@ -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')