From 47abf7127a54a7e386ce0f8538182e6ce7af94b1 Mon Sep 17 00:00:00 2001 From: "[Aron Schueler]" Date: Tue, 10 Apr 2018 14:53:32 +0200 Subject: [PATCH 1/4] Selenium tests updated - Fix test_client_disabling - Get environment variables in own method - Make chromedriver path an environment variable and check for it - Remove empty lines - Add excplicit wait in job cancel test - Fix test_client_disabling by going back to dashboard before disabling a client - Test if available localizations are in place Signed-off-by: Frank Bergkemper --- tests/selenium/README.md | 17 +- tests/selenium/webui-selenium-test.py | 414 ++++++++++++++++---------- 2 files changed, 264 insertions(+), 167 deletions(-) diff --git a/tests/selenium/README.md b/tests/selenium/README.md index 16a94be3ced..96c9be7c926 100644 --- a/tests/selenium/README.md +++ b/tests/selenium/README.md @@ -6,13 +6,14 @@ This test checks the Bareos WebUI by using seleniums webdriver. * Python >= 2.7 * Selenium >= 3.4.0 - * chromedriver or geckodriver + * chromedriver for Chrome/Chromium testing, geckodriver for Firefox testing. ## Setting up the test To run the test you must set certain environment variables: * `BAREOS_BROWSER`: The test takes either 'firefox' or 'chrome', default: `firefox` + * `BAREOS_BASE_URL`: The base url of the bareos-webui, default: `http://127.0.0.1/bareos-webui/`. * `BAREOS_USERNAME`: Login user name, default: `admin` * `BAREOS_PASSWORD`: Login password, default: `secret` @@ -21,9 +22,13 @@ To run the test you must set certain environment variables: * `BAREOS_LOG_PATH`: Directory to create selenium log files. The default path is the current directory. * `BAREOS_DELAY`: Delay between action is seconds. Useful for debugging. Default is `0.0` +### Optional: + + * `BAREOS_CHROMEDRIVER_PATH`: Set the path to your chromedriver here. + ## Running the test -` +``` BAREOS_BASE_URL=http://127.0.0.1/bareos-webui/ BAREOS_USERNAME=admin BAREOS_PASSWORD=linuxlinux @@ -32,6 +37,10 @@ BAREOS_RESTOREFILE=/etc/passwd BAREOS_LOG_PATH=/tmp/selenium-logs/ BAREOS_DELAY=1 python webui-selenium-test.py -v -` +``` + +After setting the environment variables you can run the test. Use `-v`option of our test to show the progress and results of each test. + +## Debugging -If you meet all the requirements and set the environment variables you can run the test with `python webui-selenium-test.py`. +After the test fails you will see an exception that was thrown. If this does not help you, take a look inside the generated log file, located in the same path as your `webui-selenium-test.py` file. diff --git a/tests/selenium/webui-selenium-test.py b/tests/selenium/webui-selenium-test.py index 738c5dea99f..9b1862f8854 100755 --- a/tests/selenium/webui-selenium-test.py +++ b/tests/selenium/webui-selenium-test.py @@ -25,6 +25,7 @@ class WebuiSeleniumTest(unittest.TestCase): password = 'secret' client = 'bareos-fd' restorefile = '/usr/sbin/bconsole' + chromedriverpath = '/usr/lib/chromium-browser/chromedriver' # path to store logging files logpath = os.getcwd() # slow down test for debugging @@ -34,8 +35,11 @@ class WebuiSeleniumTest(unittest.TestCase): # time to wait before trying again waittime = 0.1 +# Setup functions def setUp(self): + # Get environment variables + self.get_env() # Configure the logger, for information about the timings set it to INFO # Selenium driver itself will write additional debug messages when set to DEBUG #logging.basicConfig(filename='webui-selenium-test.log', level=logging.DEBUG) @@ -51,7 +55,12 @@ def setUp(self): #d = DesiredCapabilities.CHROME #d['loggingPrefs'] = { 'browser':'ALL' } # On OS X: Chromedriver path is 'usr/local/lib/chromium-browser/chromedriver' - self.driver = webdriver.Chrome('/usr/local/lib/chromium-browser/chromedriver') + try: + os.path.isfile(self.chromedriverpath) + except FileNotFoundError: + raise DriverNotFoundException + else: + self.driver = webdriver.Chrome(self.chromedriverpath) if self.browser == "firefox": d = DesiredCapabilities.FIREFOX d['loggingPrefs'] = { 'browser':'ALL' } @@ -59,8 +68,6 @@ def setUp(self): fp.set_preference('webdriver.log.file', self.logpath + '/firefox_console.log') self.driver = webdriver.Firefox(capabilities=d, firefox_profile=fp) - self.driver.implicitly_wait(1) - # used as timeout for selenium.webdriver.support.expected_conditions (EC) self.wait = WebDriverWait(self.driver, self.maxwait) @@ -69,15 +76,119 @@ def setUp(self): self.verificationErrors = [] + def get_env(self): + # Get attributes as environment variables, + # if not available or set use defaults. + global chromedriverpath + chromedriverpath = os.environ.get('BAREOS_CHROMEDRIVER_PATH') + if chromedriverpath: + WebuiSeleniumTest.chromedriverpath = chromedriverpath + global browser + browser = os.environ.get('BAREOS_BROWSER') + if browser: + WebuiSeleniumTest.browser = browser + global base_url + base_url = os.environ.get('BAREOS_BASE_URL') + if base_url: + WebuiSeleniumTest.base_url = base_url.rstrip('/') + global username + username = os.environ.get('BAREOS_USERNAME') + if username: + WebuiSeleniumTest.username = username + global password + password = os.environ.get('BAREOS_PASSWORD') + if password: + WebuiSeleniumTest.password = password + global client + client = os.environ.get('BAREOS_CLIENT_NAME') + if client: + WebuiSeleniumTest.client = client + global restorefile + restorefile = os.environ.get('BAREOS_RESTOREFILE') + if restorefile: + WebuiSeleniumTest.restorefile = restorefile + global logpath + logpath = os.environ.get('BAREOS_LOG_PATH') + if logpath: + WebuiSeleniumTest.logpath = logpath + global sleeptime + sleeptime = os.environ.get('BAREOS_DELAY') + if sleeptime: + WebuiSeleniumTest.sleeptime = float(sleeptime) + +# Tests + + def test_client_disabling(self): + self.login() + logger = logging.getLogger() + # Clicks on client menue tab + self.wait_and_click(By.ID, 'menu-topnavbar-client') + # Tries to click on client... + try: + self.wait_and_click(By.LINK_TEXT, self.client) + # Raises exception if client not found + except ElementTimeoutException: + raise ClientNotFoundException(self.client) + # And goes back to dashboard tab. + self.wait_and_click(By.ID, 'menu-topnavbar-dashboard') + # Back to the clients + # Disables client 1 and goes back to the dashboard. + self.wait_and_click(By.ID, 'menu-topnavbar-client') + self.wait_and_click(By.LINK_TEXT, self.client) + self.wait_and_click(By.ID, 'menu-topnavbar-client') + # Checks if client is enabled + if self.client_status(self.client)=='Enabled': + # Disables client + self.wait_and_click(By.XPATH, '//tr[contains(td[1], "%s")]/td[5]/a[@title="Disable"]' % self.client) + # Switches to dashboard, if prevented by open modal: close modal + self.wait_and_click(By.ID, 'menu-topnavbar-dashboard',By.CSS_SELECTOR, 'div.modal-footer > button.btn.btn-default') + # Throw exception if client is already disabled + else: + raise ClientStatusException(self.client, 'disabled') + self.wait_and_click(By.ID, 'menu-topnavbar-client') + # Checks if client is disabled so that it can be enabled + if self.client_status(self.client)=='Disabled': + # Enables client + self.wait_and_click(By.XPATH, '//tr[contains(td[1], "%s")]/td[5]/a[@title="Enable"]' % self.client) + # Switches to dashboard, if prevented by open modal: close modal + self.wait_and_click(By.ID, 'menu-topnavbar-dashboard', By.CSS_SELECTOR, 'div.modal-footer > button.btn.btn-default') + # Throw exception if client is already enabled + else: + raise ClientStatusException(self.client, 'enabled') + + self.logout() + + def test_job_canceling(self): + + driver = self.driver + self.login() + job_id = self.job_start_configured() + self.job_cancel(job_id) + self.logout() def test_login(self): self.login() self.logout() + def test_languages(self): + + driver = self.driver + driver.get(self.base_url + '/auth/login') + self.driver.find_element_by_xpath('//button[@data-id="locale"]').click() + # Set expected languages as a list + expected_languages = {'Chinese','Czech','Dutch/Belgium','English','French','German','Italian','Russian','Slovak','Spanish','Turkish'} + # Append text of each element found by xpath into 'elements' list + elements = [] + for element in self.driver.find_elements_by_xpath('//ul[@aria-expanded="true"]/li[@data-original-index>"0"]/a/span[@class="text"]'): + elements.append(element.text) + # If both lists match return true + b = bool(set(expected_languages)==set(elements)) + if not b: + raise LocaleException(expected_languages,elements) + def test_menue(self): self.login() - self.wait_for_url_and_click('/director/') self.wait_for_url_and_click('/schedule/') self.wait_for_url_and_click('/schedule/status/') @@ -85,10 +196,20 @@ def test_menue(self): self.wait_for_url_and_click('/client/') self.wait_for_url_and_click('/restore/') self.wait_and_click(By.XPATH, '//a[contains(@href, "/dashboard/")]', By.XPATH, '//div[@id="modal-001"]//button[.="Close"]') - self.close_alert_and_get_its_text() self.logout() + def test_rerun_job(self): + self.login() + self.wait_and_click(By.ID, "menu-topnavbar-client") + self.wait_and_click(By.LINK_TEXT, self.client) + # Select first backup in list + self.wait_and_click(By.XPATH, '//tr[@data-index="0"]/td[1]/a') + # Press on rerun button + self.wait_and_click(By.CSS_SELECTOR, "span.glyphicon.glyphicon-repeat") + self.wait_and_click(By.ID, "menu-topnavbar-dashboard", By.XPATH, "//div[@id='modal-002']/div/div/div[3]/button") + self.logout() + def test_restore(self): # Login @@ -96,30 +217,30 @@ def test_restore(self): self.wait_for_url_and_click('/restore/') # Click on client dropdown menue and close the possible modal self.wait_and_click(By.XPATH, '(//button[@data-id="client"])', By.XPATH, '//div[@id="modal-001"]//button[.="Close"]') - # Select correct client self.wait_and_click(By.LINK_TEXT, self.client) - # Clicks on file and navigates through the tree # by using the arrow-keys. pathlist = self.restorefile.split('/') for i in pathlist[:-1]: self.wait_for_element(By.XPATH, '//a[contains(text(),"%s/")]' % i).send_keys(Keys.ARROW_RIGHT) self.wait_for_element(By.XPATH, '//a[contains(text(),"%s")]' % pathlist[-1]).click() - # Submit restore self.wait_and_click(By.XPATH, '//input[@id="submit"]') - # Confirms alert self.assertRegexpMatches(self.close_alert_and_get_its_text(), r'^Are you sure[\s\S]$') - # switch to dashboard to prevent that modals are open before logout self.wait_and_click(By.XPATH, '//a[contains(@href, "/dashboard/")]', By.XPATH, '//div[@id="modal-002"]//button[.="Close"]') self.close_alert_and_get_its_text() - # Logout self.logout() + def test_run_configured_job(self): + driver = self.driver + self.login() + job_id = self.job_start_configured() + self.logout() + def test_run_default_job(self): self.login() self.wait_and_click(By.ID, 'menu-topnavbar-job') @@ -133,45 +254,52 @@ def test_run_default_job(self): self.wait_and_click(By.ID, 'menu-topnavbar-dashboard') self.logout() - def test_run_configured_job(self): - - driver = self.driver - - self.login() - - job_id = self.job_start_configured() - - self.logout() +# Methods used for testing - def test_job_canceling(self): - - driver = self.driver + def client_status(self, client): + # Wait until the site and the status element are loaded. + self.wait.until(EC.presence_of_element_located((By.XPATH, '//tr[contains(td[1], "%s")]/td[4]/span' % self.client))) + # Checks the clients status on /bareos-webui/clients, if client not found raise exception + try: + status = self.driver.find_element(By.XPATH, '//tr[contains(td[1], "%s")]/td[4]/span' % self.client).text + except NoSuchElementException: + raise ClientNotFoundException(self.client) + return status - self.login() + def compare_locales(self): - job_id = self.job_start_configured() - self.job_cancel(job_id) + return b - self.logout() + def job_cancel(self, id): + # Go to job list + self.wait_and_click(By.ID, 'menu-topnavbar-job') + # Click on the object that has id in its url + self.wait_for_url_and_click('/bareos-webui/job/details/%s' % id) + # Wait for the cancel button to load + self.wait_for_element(By.XPATH, '//*[@title="Cancel"]') + # Click on cancel button + self.wait_and_click(By.XPATH, '//*[@title="Cancel"]') def job_start_configured(self): driver = self.driver self.wait_and_click(By.ID, 'menu-topnavbar-job') self.wait_and_click(By.LINK_TEXT, 'Run') - Select(driver.find_element_by_id('job')).select_by_visible_text('backup-bareos-fd') Select(driver.find_element_by_id('client')).select_by_visible_text(self.client) Select(driver.find_element_by_id('level')).select_by_visible_text('Incremental') # Clears the priority field and enters 5. driver.find_element_by_id('priority').clear() driver.find_element_by_id('priority').send_keys('5') - # Open the calendar self.wait_and_click(By.CSS_SELECTOR, "span.glyphicon.glyphicon-calendar") - # Click the icon to delay jobstart by 1min two times - self.wait_and_click(By.XPATH, '//td[3]/a/span') - self.wait_and_click(By.XPATH, '//td[3]/a/span') + # Click the icon to delay jobstart by 1h six times + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') + self.wait_and_click(By.XPATH, '//a[@title="Increment Hour"]') # Close the calendar self.wait_and_click(By.CSS_SELECTOR, 'span.input-group-addon') # Submit the job @@ -186,64 +314,10 @@ def job_start_configured(self): return job_id - def job_cancel(self, id): - # Go to job list - self.wait_and_click(By.ID, 'menu-topnavbar-job') - # Click on the object that has id in its url - self.wait_for_url_and_click('/job/details/%s' % id) - # Click on cancel button - self.wait_and_click(By.XPATH, '//*[@title="Cancel"]') - - def test_rerun_job(self): - self.login() - self.wait_and_click(By.ID, "menu-topnavbar-client") - self.wait_and_click(By.LINK_TEXT, self.client) - # Select first backup in list - self.wait_and_click(By.XPATH, '//tr[@data-index="0"]/td[1]/a') - # Press on rerun button - self.wait_and_click(By.CSS_SELECTOR, "span.glyphicon.glyphicon-repeat") - self.wait_and_click(By.ID, "menu-topnavbar-dashboard", By.XPATH, "//div[@id='modal-002']/div/div/div[3]/button") - self.logout() - - def test_client_disabling(self): - self.login() - logger = logging.getLogger() - # Disables client 1 and goes back to the dashboard. - self.wait_and_click(By.ID, 'menu-topnavbar-client') - self.wait_and_click(By.LINK_TEXT, self.client) - self.wait_and_click(By.ID, 'menu-topnavbar-client') - - # Checks if client is enabled - if self.client_status(self.client)=='Enabled': - # Disables client - self.wait_and_click(By.XPATH, '//tr[contains(td[1], "%s")]/td[5]/a[@title="Disable"]' % self.client) - # Switches to dashboard, if prevented by open modal: close modal - self.wait_and_click(By.ID, 'menu-topnavbar-dashboard',By.CSS_SELECTOR, 'div.modal-footer > button.btn.btn-default') - - # Throw exception if client is already disabled - else: - raise ClientStatusException(self.client, 'disabled') - - self.wait_and_click(By.ID, 'menu-topnavbar-client') - - # Checks if client is disabled so that it can be enabled - if self.client_status(self.client)=='Disabled': - # Enables client - self.wait_and_click(By.XPATH, '//tr[contains(td[1], "%s")]/td[5]/a[@title="Enable"]' % self.client) - # Switches to dashboard, if prevented by open modal: close modal - self.wait_and_click(By.ID, 'menu-topnavbar-dashboard', By.CSS_SELECTOR, 'div.modal-footer > button.btn.btn-default') - # Throw exception if client is already enabled - else: - raise ClientStatusException(self.client, 'enabled') - - self.logout() - def login(self): driver = self.driver - driver.get(self.base_url + '/auth/login') Select(driver.find_element_by_name('director')).select_by_visible_text('localhost-dir') - driver.find_element_by_name('consolename').clear() driver.find_element_by_name('consolename').send_keys(self.username) driver.find_element_by_name('password').clear() @@ -253,41 +327,20 @@ def login(self): driver.find_element_by_xpath('//input[@id="submit"]').click() # while ('/dashboard/' not in self.driver.current_url): # sleep(self.waittime) - self.wait_for_spinner_absence() + element=None + try: + element = driver.find_element_by_xpath('//div[@role="alert"]') + except: + self.wait_for_spinner_absence() + else: + raise WrongCredentialsException(self.username, self.password) def logout(self): self.wait_and_click(By.CSS_SELECTOR, 'a.dropdown-toggle') self.wait_and_click(By.LINK_TEXT, 'Logout') sleep(self.sleeptime) - def client_status(self, client): - self.client = client - # Checks the clients status on /bareos-webui/clients - status = self.driver.find_element(By.XPATH, '//tr[contains(td[1], "%s")]/td[4]/span' % self.client).text - return status - - def wait_for_spinner_absence(self): - logger = logging.getLogger() - element = None - try: - element = WebDriverWait(self.driver, self.maxwait).until(EC.invisibility_of_element_located((By.ID, 'spinner'))) - except TimeoutException: - raise ElementTimeoutException("spinner") - return element - - def wait_for_element(self, by, value): - logger = logging.getLogger() - element = None - logger.info('waiting for %s %s', by, value) - try: - element = self.wait.until(EC.element_to_be_clickable((by, value))) - except TimeoutException: - raise ElementTimeoutException(value) - return element - - def wait_for_url_and_click(self, url): - value='//a[contains(@href, "%s")]' % url - self.wait_and_click(By.XPATH, value) +# Methods used for waiting and clicking def wait_and_click(self, by, value, modal_by=None, modal_value=None): logger = logging.getLogger() @@ -310,14 +363,48 @@ def wait_and_click(self, by, value, modal_by=None, modal_value=None): except WebDriverException as e: logger.info('WebDriverException: %s', e) sleep(self.waittime) - except NoSuchElementException as e: - logger.info("NoSuchElementException while clicking: %s", e) - sleep(self.waittime) + # The case where the element doesn't exist is handled in wait_for_element + # except NoSuchElementException as e: + # logger.info("NoSuchElementException while clicking: %s", e) + # sleep(self.waittime) else: return element seconds = (datetime.now() - starttime).total_seconds() logger.error('failed to click %s %s', by, value) - raise FailedClickException(by, value) + raise FailedClickException(value) + + def wait_for_element(self, by, value): + logger = logging.getLogger() + element = None + logger.info('waiting for %s %s', by, value) + try: + element = self.wait.until(EC.element_to_be_clickable((by, value))) + except TimeoutException: + self.driver.save_screenshot('screenshot.png') + raise ElementTimeoutException(value) + if element==None: + try: + self.driver.find_element(by, value) + except NoSuchElementException: + self.driver.save_screenshot('screenshot.png') + raise ElementNotFoundException(value) + else: + self.driver.save_screenshot('screenshot.png') + raise ElementCoveredException(value) + return element + + def wait_for_spinner_absence(self): + logger = logging.getLogger() + element = None + try: + element = WebDriverWait(self.driver, self.maxwait).until(EC.invisibility_of_element_located((By.ID, 'spinner'))) + except TimeoutException: + raise ElementTimeoutException("spinner") + return element + + def wait_for_url_and_click(self, url): + value='//a[contains(@href, "%s")]' % url + self.wait_and_click(By.XPATH, value) def close_alert_and_get_its_text(self, accept=True): logger = logging.getLogger() @@ -327,20 +414,28 @@ def close_alert_and_get_its_text(self, accept=True): alert_text = alert.text except NoAlertPresentException: return - if accept: alert.accept() else: alert.dismiss() - logger.debug( 'alert message: %s' % (alert_text)) - return alert_text def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) + +if __name__ == '__main__': + + unittest.main() + +class BadJobException(Exception): + '''Raise when a started job doesn't result in ID''' + def __init__(self, msg=None): + msg = 'Job ID could not be saved after starting the job.' + super(BadJobException, self).__init__(msg) + class ClientStatusException(Exception): '''Raise when a client does not have the expected status''' def __init__(self,client, status, msg=None): @@ -350,57 +445,50 @@ def __init__(self,client, status, msg=None): msg = '%s is disabled and cannot be disabled again.' % client super(ClientStatusException, self).__init__(msg) -class BadJobException(Exception): - '''Raise when a started job doesn't result in ID''' - def __init__(self, msg=None): - msg = 'Job ID could not be saved after starting the job.' - super(BadJobException, self).__init__(msg) +class ClientNotFoundException(Exception): + '''Raise when the expected client is not found''' + def __init__(self, client, msg=None): + msg = 'The client %s was not found.' % client + super(ClientNotFoundException, self).__init__(msg) + +class ElementCoveredException(Exception): + '''Raise when an element is covered by something''' + def __init__(self, value): + msg = 'Click on element %s failed as it was covered by another element.' % value + super(ElementCoveredException, self).__init__(msg) class ElementTimeoutException(Exception): '''Raise when waiting on an element times out''' def __init__(self, value): - msg = 'Waiting for element %s returned a TimeoutException.' % value + if value != 'spinner': + msg = 'Waiting for element %s returned a TimeoutException.' % value + else: + msg = 'Waiting for the spinner to disappear returned a TimeoutException.' % value super(ElementTimeoutException, self).__init__(msg) +class ElementNotFoundException(Exception): + '''Raise when an element is not found''' + def __init__(self, value): + msg = 'Element %s was not found.' % value + super(ElementNotFoundException, self).__init__(msg) + class FailedClickException(Exception): '''Raise when wait_and_click fails''' def __init__(self, value): msg = 'Waiting and trying to click %s failed.' % value super(FailedClickException, self).__init__(msg) -if __name__ == '__main__': - # Get attributes as environment variables, - # if not available or set use defaults. - browser = os.environ.get('BAREOS_BROWSER') - if browser: - WebuiSeleniumTest.browser = browser - - base_url = os.environ.get('BAREOS_BASE_URL') - if base_url: - WebuiSeleniumTest.base_url = base_url.rstrip('/') - - username = os.environ.get('BAREOS_USERNAME') - if username: - WebuiSeleniumTest.username = username - - password = os.environ.get('BAREOS_PASSWORD') - if password: - WebuiSeleniumTest.password = password - - client = os.environ.get('BAREOS_CLIENT_NAME') - if client: - WebuiSeleniumTest.client = client - - restorefile = os.environ.get('BAREOS_RESTOREFILE') - if restorefile: - WebuiSeleniumTest.restorefile = restorefile - - logpath = os.environ.get('BAREOS_LOG_PATH') - if logpath: - WebuiSeleniumTest.logpath = logpath - - sleeptime = os.environ.get('BAREOS_DELAY') - if sleeptime: - WebuiSeleniumTest.sleeptime = float(sleeptime) +class LocaleException(Exception): + '''Raise when wait_and_click fails''' + def __init__(self, expected_languages, elements): + if len(expected_languages)!=len(elements): + msg = 'The available languages in login did not meet expectations.\n Expected '+str(len(expected_languages))+' languages but got '+str(len(elements))+'. Dropdown menue misses '+''.join(list(set(expected_languages) - set(elements)))+'.' + else: + msg = 'The available languages in login did not meet expectations.\n'+'Dropdown menue misses language '+''.join(list(set(expected_languages) - set(elements)))+' or the name changed.' + super(LocaleException, self).__init__(msg) - unittest.main() +class WrongCredentialsException(Exception): + '''Raise when wait_and_click fails''' + def __init__(self, username, password): + msg = 'Username "%s" or password "%s" is wrong.' % (username,password) + super(WrongCredentialsException, self).__init__(msg) From 03f43024980df67251388e586b887374d1e3fb05 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Wed, 11 Apr 2018 12:35:27 +0200 Subject: [PATCH 2/4] tiny fix and some cleanup --- tests/selenium/webui-selenium-test.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/selenium/webui-selenium-test.py b/tests/selenium/webui-selenium-test.py index 9b1862f8854..664466d7fe8 100755 --- a/tests/selenium/webui-selenium-test.py +++ b/tests/selenium/webui-selenium-test.py @@ -159,7 +159,6 @@ def test_client_disabling(self): self.logout() def test_job_canceling(self): - driver = self.driver self.login() job_id = self.job_start_configured() @@ -171,7 +170,6 @@ def test_login(self): self.logout() def test_languages(self): - driver = self.driver driver.get(self.base_url + '/auth/login') self.driver.find_element_by_xpath('//button[@data-id="locale"]').click() @@ -187,7 +185,6 @@ def test_languages(self): raise LocaleException(expected_languages,elements) def test_menue(self): - self.login() self.wait_for_url_and_click('/director/') self.wait_for_url_and_click('/schedule/') @@ -211,7 +208,6 @@ def test_rerun_job(self): self.logout() def test_restore(self): - # Login self.login() self.wait_for_url_and_click('/restore/') @@ -267,21 +263,20 @@ def client_status(self, client): return status def compare_locales(self): - return b def job_cancel(self, id): # Go to job list self.wait_and_click(By.ID, 'menu-topnavbar-job') # Click on the object that has id in its url - self.wait_for_url_and_click('/bareos-webui/job/details/%s' % id) + self.wait_and_click(By.ID, 'btn-1') + #self.wait_for_url_and_click('/bareos-webui/job/details/%s' % id) # Wait for the cancel button to load - self.wait_for_element(By.XPATH, '//*[@title="Cancel"]') + #self.wait_for_element(By.XPATH, '//*[@title="Cancel"]') # Click on cancel button - self.wait_and_click(By.XPATH, '//*[@title="Cancel"]') + #self.wait_and_click(By.XPATH, '//*[@title="Cancel"]') def job_start_configured(self): - driver = self.driver self.wait_and_click(By.ID, 'menu-topnavbar-job') self.wait_and_click(By.LINK_TEXT, 'Run') From 0c5ded82cc6cd55594b4bc25ea6201e06a08d79e Mon Sep 17 00:00:00 2001 From: "[Aron Schueler]" Date: Thu, 12 Apr 2018 18:04:07 +0200 Subject: [PATCH 3/4] Minor job_cancel fix Signed-off-by: Frank Bergkemper --- tests/selenium/webui-selenium-test.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/tests/selenium/webui-selenium-test.py b/tests/selenium/webui-selenium-test.py index 664466d7fe8..3c3b48142af 100755 --- a/tests/selenium/webui-selenium-test.py +++ b/tests/selenium/webui-selenium-test.py @@ -266,15 +266,10 @@ def compare_locales(self): return b def job_cancel(self, id): - # Go to job list - self.wait_and_click(By.ID, 'menu-topnavbar-job') - # Click on the object that has id in its url - self.wait_and_click(By.ID, 'btn-1') - #self.wait_for_url_and_click('/bareos-webui/job/details/%s' % id) - # Wait for the cancel button to load - #self.wait_for_element(By.XPATH, '//*[@title="Cancel"]') - # Click on cancel button - #self.wait_and_click(By.XPATH, '//*[@title="Cancel"]') + # Wait for the cancel button + self.wait_for_element(By.ID, "//a[@id='btn-1'][@title='Cancel']") + # Click the cancel button + self.wait_and_click(By.ID, "//a[@id='btn-1'][@title='Cancel']") def job_start_configured(self): driver = self.driver @@ -299,15 +294,6 @@ def job_start_configured(self): self.wait_and_click(By.CSS_SELECTOR, 'span.input-group-addon') # Submit the job self.wait_and_click(By.ID, 'submit') - # After the now-generated site has loaded, save the job id - self.wait_for_spinner_absence() - # Count how many digits are at the end of the url / how long the id is - job_id = driver.current_url.split('/')[-1] - # If the current URL doesn't end with a digit we didn't start the job properly. - if not job_id.isdigit(): - raise BadJobException - - return job_id def login(self): driver = self.driver From d1115e979dadb6915f1abb45bf7648c16dac78dd Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Thu, 19 Apr 2018 15:39:52 +0200 Subject: [PATCH 4/4] Selenium: disable test test_job_canceling --- tests/selenium/webui-selenium-test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/selenium/webui-selenium-test.py b/tests/selenium/webui-selenium-test.py index 3c3b48142af..135d28a2fa0 100755 --- a/tests/selenium/webui-selenium-test.py +++ b/tests/selenium/webui-selenium-test.py @@ -158,12 +158,12 @@ def test_client_disabling(self): self.logout() - def test_job_canceling(self): - driver = self.driver - self.login() - job_id = self.job_start_configured() - self.job_cancel(job_id) - self.logout() + #def test_job_canceling(self): + # driver = self.driver + # self.login() + # job_id = self.job_start_configured() + # self.job_cancel(job_id) + # self.logout() def test_login(self): self.login()