Make submitting logins for Selenium tests a bit more robust.

There are a few different transiently failing tests on Jenkins that seem to fail because the test thinks Galaxy is logged in but it is not. So now after we click the login button in Selenium - we will wait for to see the "Register or Login" button turn into the "User" button.

This is a similar problem and fix to what was done in #4562 - which seemed to help.
This commit is contained in:
John Chilton
2017-09-07 15:51:38 -04:00
parent 2aeb4590d1
commit 46b799dfbb
2 changed files with 22 additions and 7 deletions
+18 -3
View File
@@ -216,7 +216,7 @@ class NavigatesGalaxy(HasDriver):
domain = domain or 'test.test'
return self._get_random_name(prefix=username, suffix="@" + domain)
def submit_login(self, email, password=None):
def submit_login(self, email, password=None, assert_valid=True):
if password is None:
password = self.default_password
@@ -233,6 +233,9 @@ class NavigatesGalaxy(HasDriver):
self.fill(form, login_info)
self.click_submit(form)
if assert_valid:
self.wait_for_logged_in()
def register(self, email=None, password=None, username=None, confirm=None, assert_valid=True):
if email is None:
email = self._get_random_email()
@@ -257,9 +260,18 @@ class NavigatesGalaxy(HasDriver):
))
self.click_xpath(self.navigation_data["selectors"]["registrationPage"]["submit_xpath"])
# Give the browser a bit of time to submit the request.
time.sleep(.25)
# It would be good to eliminate this sleep, but it can't be because Galaxy
# doesn't swap the "User" menu automatically after it registers a user and
# and the donemessage visible comment below doesn't work when using Selenium.
# Something about the Selenium session or quickness of registering causes the
# following in the Galaxy logs which gets propaged to the GUI as a generic error:
# /api/histories/cfc05ccec54895e2/contents?keys=type_id%2Celement_count&order=hid&v=dev&q=history_content_type&q=deleted&q=purged&q=visible&qv=dataset_collection&qv=False&qv=False&qv=True HTTP/1.1" 403 - "http://localhost:8080/"
# Like the logged in user doesn't have permission to the previously anonymous user's
# history, it is odd but I cannot replicate this outside of Selenium.
time.sleep(.35)
if assert_valid:
# self.wait_for_selector_visible(".donemessage")
self.home()
self.click_masthead_user()
# Make sure the user menu was dropped down
@@ -279,6 +291,9 @@ class NavigatesGalaxy(HasDriver):
# Hide masthead menu click
self.click_center()
def wait_for_logged_in(self):
self.wait_for_selector_visible("a.loggedin-only")
def click_center(self):
action_chains = self.action_chains()
center_element = self.driver.find_element_by_css_selector("#center")
@@ -746,7 +761,7 @@ class NavigatesGalaxy(HasDriver):
raise AssertionError(message)
def assert_no_error_message(self):
self.assert_selector_absent(self.test_data["selectors"]["messages"]["error"])
self.wait_for_selector_absent(self.test_data["selectors"]["messages"]["error"])
def run_tour_step(self, step, step_index, tour_callback):
preclick = step.get("preclick", [])
+4 -4
View File
@@ -10,7 +10,7 @@ class LoginTestCase(SeleniumTestCase):
self.register(email)
self.logout_if_needed()
self.home()
self.submit_login(email)
self.submit_login(email, assert_valid=True)
with self.main_panel():
self.assert_no_error_message()
assert self.is_logged_in()
@@ -20,7 +20,7 @@ class LoginTestCase(SeleniumTestCase):
bad_emails = ['test2@test.org', 'test', '', "'; SELECT * FROM galaxy_user WHERE 'u' = 'u';"]
for bad_email in bad_emails:
self.home()
self.submit_login(bad_email)
self.submit_login(bad_email, assert_valid=False)
with self.main_panel():
self.assert_error_message()
@@ -29,7 +29,7 @@ class LoginTestCase(SeleniumTestCase):
bad_passwords = ['1234', '', '; SELECT * FROM galaxy_user']
for bad_password in bad_passwords:
self.home()
self.submit_login(self._get_random_email(), password=bad_password)
self.submit_login(self._get_random_email(), password=bad_password, assert_valid=False)
with self.main_panel():
self.assert_error_message()
@@ -39,6 +39,6 @@ class LoginTestCase(SeleniumTestCase):
self.register(email)
self.logout_if_needed()
self.home()
self.submit_login(email, password="12345678")
self.submit_login(email, password="12345678", assert_valid=False)
with self.main_panel():
self.assert_error_message()