mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
This continues a thread started in 0650978a91 and #4732 of switching to smarter selectors from a more structured YAML description of the Galaxy DOM. This continues that by:
- Eliminating any use of the old navigation YAML file (navigation-data.yml).
- Replace href selectors with other things since they break when testing Galaxy with a proxy-prefix.
- Extending the raw selectors to allow concept of nesting selectors.
- Building even smarter "components" that wrap these raw selectors generated from the YAML directly in a way that allows them to utilize the actual Selenium session and helper class.
So the old ``self.navigation_data`` is gone, ``self.navigation`` still yields the raw selectors, and ``self.components`` yields the smarter variant. Hopefully all will agree the code that uses ``self.components`` is more compact and readable.
The following a very basic example of this:
```diff
def click_masthead_user(self):
- self.wait_for_and_click(self.navigation.masthead.selectors.user)
+ self.components.masthead.user.wait_for_and_click()
```
Here is an example of combining it with the new child selector syntax:
```diff
def assert_item_dbkey_displayed_as(self, hid, dbkey):
- item_body_selector = self.history_panel_item_body_selector(hid=hid, wait=True)
- dbkey_selector = item_body_selector + ' ' + self.test_data["historyPanel"]["selectors"]["hda"]["dbkey"]
- dbkey_element = self.wait_for_selector_visible(dbkey_selector)
- assert dbkey in dbkey_element.text
+ item_body = self.history_panel_item_component(hid=hid)
+ dbkey_text = item_body.dbkey.wait_for_text()
+ assert dbkey in dbkey_text
```
92 lines
3.2 KiB
Python
92 lines
3.2 KiB
Python
from .framework import (
|
|
selenium_test,
|
|
SeleniumTestCase
|
|
)
|
|
|
|
|
|
class RegistrationTestCase(SeleniumTestCase):
|
|
|
|
@selenium_test
|
|
def test_landing(self):
|
|
# loading galaxy homepage
|
|
self.home()
|
|
assert self.driver.title == "Galaxy", self.driver.title
|
|
self.assert_xpath("//div[@id='masthead']")
|
|
|
|
@selenium_test
|
|
def test_registration(self):
|
|
self.home()
|
|
self.register()
|
|
|
|
@selenium_test
|
|
def test_logout(self):
|
|
self.home()
|
|
self.register()
|
|
assert self.is_logged_in()
|
|
self.logout_if_needed()
|
|
assert not self.is_logged_in()
|
|
self.home()
|
|
self.components.masthead.user_email.assert_absent_or_hidden()
|
|
|
|
@selenium_test
|
|
def test_reregister_email_fails(self):
|
|
self.home()
|
|
email = self._get_random_email()
|
|
password = self.default_password
|
|
confirm = password
|
|
username = email.split("@")[0]
|
|
self.register(email, password, username, confirm)
|
|
self.logout_if_needed()
|
|
self.register(email, password, username, confirm, assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message()
|
|
|
|
@selenium_test
|
|
def test_reregister_username_fails(self):
|
|
self.home()
|
|
email1 = self._get_random_email()
|
|
email2 = self._get_random_email()
|
|
password = self.default_password
|
|
confirm = password
|
|
username = email1.split("@")[0]
|
|
self.register(email1, password, username, confirm)
|
|
self.logout_if_needed()
|
|
self.register(email2, password, username, confirm, assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message(contains='Public name is taken; please choose another')
|
|
|
|
@selenium_test
|
|
def test_bad_emails(self):
|
|
bad_emails = ['bob', 'bob@', 'bob@idontwanttocleanup', 'bob.cantmakeme']
|
|
good_email = self._get_random_email()
|
|
password = self.default_password
|
|
confirm = password
|
|
username = good_email.split("@")[0]
|
|
|
|
for bad_email in bad_emails:
|
|
self.register(bad_email, password, username, confirm, assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message(contains='The format of the email address is not correct.')
|
|
|
|
@selenium_test
|
|
def test_short_password(self):
|
|
self.register(password="1234", assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message(contains='Use a password of at least 6 characters')
|
|
|
|
@selenium_test
|
|
def test_password_confirmation(self):
|
|
bad_confirms = ['1234', '12345678', '123456 7', '']
|
|
for bad_confirm in bad_confirms:
|
|
self.register(confirm=bad_confirm, assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message(contains='Passwords don\'t match')
|
|
|
|
@selenium_test
|
|
def test_bad_usernames(self):
|
|
bad_usernames = ['BOBERT', 'Robert Paulson', 'bobert!']
|
|
for bad_username in bad_usernames:
|
|
self.register(username=bad_username, assert_valid=False)
|
|
with self.main_panel():
|
|
self.assert_error_message(contains='Public name must contain only ')
|