mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +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
```
103 lines
3.8 KiB
Python
103 lines
3.8 KiB
Python
from .framework import (
|
|
retry_assertion_during_transitions,
|
|
selenium_test,
|
|
SharedStateSeleniumTestCase,
|
|
)
|
|
|
|
|
|
class CustomBuildsTestcase(SharedStateSeleniumTestCase):
|
|
|
|
@selenium_test
|
|
def test_build_add(self):
|
|
self._login()
|
|
|
|
self.navigate_to_custom_builds_page()
|
|
|
|
self.add_custom_build(self.build_name1, self.build_key1)
|
|
self.assert_custom_builds_in_grid([self.build_name1])
|
|
|
|
@selenium_test
|
|
def test_build_delete(self):
|
|
self._login()
|
|
|
|
self.navigate_to_custom_builds_page()
|
|
|
|
self.add_custom_build(self.build_name2, self.build_key2)
|
|
self.assert_custom_builds_in_grid([self.build_name2])
|
|
|
|
self.delete_custom_build(self.build_name2)
|
|
self.assert_custom_builds_in_grid([self.build_name2], False)
|
|
|
|
@retry_assertion_during_transitions
|
|
def assert_custom_builds_in_grid(self, expected_builds, present=True):
|
|
actual_builds = self.get_custom_builds()
|
|
intersection = set(actual_builds).intersection(expected_builds)
|
|
if present:
|
|
self.assertEqual(intersection, set(expected_builds))
|
|
else:
|
|
self.assertEqual(intersection, set())
|
|
|
|
def _login(self):
|
|
self.home() # ensure Galaxy is loaded
|
|
self.submit_login(self.user_email, retries=2)
|
|
|
|
def add_custom_build(self, build_name, build_key):
|
|
name_div = self.wait_for_selector('div[tour_id="name"')
|
|
name_input = name_div.find_element_by_css_selector('.ui-form-field input')
|
|
name_input.click()
|
|
name_input.send_keys(build_name)
|
|
|
|
key_div = self.wait_for_selector('div[tour_id="id"')
|
|
key_input = key_div.find_element_by_css_selector('.ui-form-field input')
|
|
key_input.click()
|
|
key_input.send_keys(build_key)
|
|
|
|
len_type_div = self.wait_for_selector('div[tour_id="len|type')
|
|
len_type_select = len_type_div.find_element_by_css_selector('.ui-form-field .ui-select')
|
|
len_type_select.click()
|
|
|
|
option = self.wait_for_sizzle_selector_clickable('div[role="option"]:contains("Len-file by copy/paste")')
|
|
option.click()
|
|
content_area = self.wait_for_and_click_selector('.ui-form-field > textarea')
|
|
content_area.send_keys('content')
|
|
|
|
self.wait_for_and_click_selector('button#save')
|
|
|
|
def delete_custom_build(self, build_name):
|
|
delete_button = None
|
|
grid = self.wait_for_selector('table.grid > tbody')
|
|
for row in grid.find_elements_by_tag_name('tr'):
|
|
td = row.find_elements_by_tag_name('td')
|
|
name = td[0].text
|
|
if name == build_name:
|
|
delete_button = td[3].find_element_by_css_selector('.ui-button-icon-plain')
|
|
break
|
|
|
|
if delete_button is None:
|
|
raise AssertionError('Failed to find custom build with name [%s]' % build_name)
|
|
|
|
delete_button.click()
|
|
|
|
def get_custom_builds(self):
|
|
self.sleep_for(self.wait_types.UX_RENDER)
|
|
builds = []
|
|
grid = self.wait_for_selector('table.grid > tbody')
|
|
for row in grid.find_elements_by_tag_name('tr'):
|
|
name = row.find_elements_by_tag_name('td')[0].text
|
|
builds.append(name)
|
|
return builds
|
|
|
|
def navigate_to_custom_builds_page(self):
|
|
self.home()
|
|
self.click_masthead_user() # Open masthead menu
|
|
self.components.masthead.custom_builds.wait_for_and_click()
|
|
|
|
def setup_shared_state(self):
|
|
CustomBuildsTestcase.user_email = self._get_random_email()
|
|
self.register(self.user_email)
|
|
|
|
CustomBuildsTestcase.build_name1 = self._get_random_name()
|
|
CustomBuildsTestcase.build_name2 = self._get_random_name()
|
|
CustomBuildsTestcase.build_key1 = self._get_random_name(len=5)
|
|
CustomBuildsTestcase.build_key2 = self._get_random_name(len=5)
|