Initial tool form and dataset detail selenium testing.

- Test parameters and tables appear on dataset details page after running a tool.
- Test a simple tool execution with an integer field.
- Test re-run a tool.
- Test a tool with a data drop down.
- Improved select2 abstractions.
This commit is contained in:
John Chilton
2016-12-20 12:34:50 -05:00
parent 64b0d03260
commit cc32dcae4b
5 changed files with 219 additions and 32 deletions
+11 -2
View File
@@ -150,7 +150,16 @@
</h2>
<h3>Dataset Information</h3>
<table class="tabletip">
<table class="tabletip" id="dataset-details">
<thead>
<tr><th colspan="2" style="font-size: 120%;">
% if tool:
Tool: ${tool.name | h}
% else:
Unknown Tool
% endif
</th></tr>
</thead>
<tbody>
<%
encoded_hda_id = trans.security.encode_id( hda.id )
@@ -194,7 +203,7 @@
</table>
<h3>Tool Parameters</h3>
<table class="tabletip">
<table class="tabletip" id="tool-parameters">
<thead>
<tr>
<th>Input Parameter</th>
+59
View File
@@ -200,6 +200,29 @@ class NavigatesGalaxy(HasDriver):
close_button = self.wait_for_selector("button#btn-close")
close_button.click()
def tool_open(self, tool_id):
link_element = self.wait_for_selector('a[href$="tool_runner?tool_id=%s"]' % tool_id)
link_element.click()
def tool_parameter_div(self, expanded_parameter_id):
return self.wait_for_selector("div.ui-form-element[tour_id$='%s']" % expanded_parameter_id)
def tool_set_value(self, expanded_parameter_id, value, expected_type=None, test_data_resolver=None):
div_element = self.tool_parameter_div(expanded_parameter_id)
assert div_element
if expected_type == "data":
div_selector = "div.ui-form-element[tour_id$='%s']" % expanded_parameter_id
self.select2_set_value(div_selector, value)
else:
input_element = div_element.find_element_by_css_selector("input")
# Clear default value
input_element.clear()
input_element.send_keys(value)
def tool_execute(self):
execute_button = self.wait_for_selector("button#execute")
execute_button.click()
def click_masthead_user(self):
self.click_xpath(self.navigation_data["selectors"]["masthead"]["user"])
@@ -240,6 +263,18 @@ class NavigatesGalaxy(HasDriver):
def hda_body_selector(self, hda_id):
return "%s %s" % (self.hda_div_selector(hda_id), self.test_data["historyPanel"]["selectors"]["hda"]["body"])
def hda_click_primary_action_button(self, hda_id, button_key):
self.click_hda_title(hda_id, wait=True)
body_selector = self.hda_body_selector(hda_id)
buttons_selector = body_selector + " " + self.test_data["historyPanel"]["selectors"]["hda"]["primaryActionButtons"]
self.wait_for_selector_visible(buttons_selector)
button_def = self.test_data["historyPanel"]["hdaPrimaryActionButtons"][button_key]
button_selector = button_def["selector"]
button_item = self.wait_for_selector_visible("%s %s" % (buttons_selector, button_selector))
return button_item.click()
def click_hda_title(self, hda_id, wait=False):
expand_target = "%s .title" % self.hda_div_selector(hda_id)
hda_element = self.wait_for_selector(expand_target)
@@ -345,3 +380,27 @@ class NavigatesGalaxy(HasDriver):
print("(Post)Clicking %s" % postclick_selector)
element = self.tour_wait_for_clickable_element(postclick_selector)
element.click()
def select2_set_value(self, container_selector, value, with_click=True):
# There are two hacky was to select things from the select2 widget -
# with_click=True: This simulates the mouse click after the suggestion contains
# only the selected value.
# with_click=False: This presses enter on the selection. Not sure
# why.
# with_click seems to work in all situtations - the enter methods
# doesn't seem to work with the tool form for some reason.
container_elem = self.wait_for_selector(container_selector)
text_element = container_elem.find_element_by_css_selector("input[type='text']")
text_element.send_keys(value)
# Wait for select2 options to load and then click to add this one.
drop_elem = self.wait_for_selector_visible("#select2-drop")
# Sleep seems to be needed - at least for send_enter.
time.sleep(.5)
if not with_click:
# Wait for select2 options to load and then click to add this one.
self.send_enter(text_element)
else:
select_elem = drop_elem.find_elements_by_css_selector(".select2-result-label")[0]
action_chains = self.action_chains()
action_chains.move_to_element(select_elem).click().perform()
self.wait_for_selector_absent_or_hidden("#select2-drop")
@@ -4,28 +4,7 @@ from .framework import SeleniumTestCase
from .framework import selenium_test
class HistoryDatasetStateTestCase(SeleniumTestCase):
@selenium_test
def test_dataset_state(self):
self.register()
self.perform_upload(self.get_filename("1.fasta"))
self.wait_for_history()
hda_id = self.latest_history_item()["id"]
item_selector = self.hda_div_selector(hda_id)
self.assert_item_name(item_selector, "1.fasta")
self.assert_item_hid(item_selector, "1")
self.assert_title_buttons(item_selector)
self.click_hda_title(hda_id, wait=True)
hda_body_selector = self.hda_body_selector(hda_id)
self.wait_for_selector_visible(hda_body_selector)
self.assert_item_summary_includes(hda_body_selector, "1 sequence")
self.assert_dbkey_display_as(hda_body_selector, "?")
self.assert_info_includes(hda_body_selector, 'uploaded fasta file')
self.assert_action_buttons(hda_body_selector)
self.assert_peek_includes(hda_body_selector, ">hg17")
class UsesHistoryItemAssertions:
def assert_action_buttons(self, body_selector, expected_buttons=["info", "download"]):
buttons_selector = body_selector + " " + self.test_data["historyPanel"]["selectors"]["hda"]["primaryActionButtons"]
@@ -80,3 +59,27 @@ class HistoryDatasetStateTestCase(SeleniumTestCase):
button_item = self.wait_for_selector_visible("%s %s" % (buttons_area, selector))
expected_tooltip = button_def.get("tooltip")
self.assert_tooltip_text(button_item, expected_tooltip)
class HistoryDatasetStateTestCase(SeleniumTestCase, UsesHistoryItemAssertions):
@selenium_test
def test_dataset_state(self):
self.register()
self.perform_upload(self.get_filename("1.fasta"))
self.wait_for_history()
hda_id = self.latest_history_item()["id"]
item_selector = self.hda_div_selector(hda_id)
self.assert_item_name(item_selector, "1.fasta")
self.assert_item_hid(item_selector, "1")
self.assert_title_buttons(item_selector)
self.click_hda_title(hda_id, wait=True)
hda_body_selector = self.hda_body_selector(hda_id)
self.wait_for_selector_visible(hda_body_selector)
self.assert_item_summary_includes(hda_body_selector, "1 sequence")
self.assert_dbkey_display_as(hda_body_selector, "?")
self.assert_info_includes(hda_body_selector, 'uploaded fasta file')
self.assert_action_buttons(hda_body_selector)
self.assert_peek_includes(hda_body_selector, ">hg17")
+3 -8
View File
@@ -1,5 +1,3 @@
import time
from .framework import SeleniumTestCase
from .framework import selenium_test
@@ -108,10 +106,7 @@ class HistorySharingTestCase(SeleniumTestCase):
def share_history_with_user(self, email):
self.navigate_to_history_user_share_page()
form = self.wait_for_selector("form#share")
text_element = form.find_element_by_css_selector("input[type='text']")
text_element.send_keys(email)
# Wait for select2 options to load and then click to add this one.
time.sleep(2)
self.send_enter(text_element)
form_selector = "form#share"
form = self.wait_for_selector(form_selector)
self.select2_set_value(form_selector, email)
self.click_submit(form)
+121
View File
@@ -0,0 +1,121 @@
from .framework import SeleniumTestCase
from .framework import selenium_test
from .test_history_dataset_state import UsesHistoryItemAssertions
class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions):
@selenium_test
def test_run_tool_verify_contents_by_peek(self):
self._run_environment_test_tool()
self.wait_for_history()
hda_id = self.latest_history_item()["id"]
self.click_hda_title(hda_id, wait=True)
hda_body_selector = self.hda_body_selector(hda_id)
self.wait_for_selector_visible(hda_body_selector)
self.assert_peek_includes(hda_body_selector, "42")
@selenium_test
def test_run_tool_verify_dataset_details(self):
self._run_environment_test_tool()
self.wait_for_history()
hda_id = self.latest_history_item()["id"]
self._check_dataset_details_for_inttest_value(hda_id)
@selenium_test
def test_verify_dataset_details_tables(self):
self._run_environment_test_tool()
self.wait_for_history()
hda = self.latest_history_item()
hda_id = hda["id"]
self._check_dataset_details_for_inttest_value(hda_id)
dataset_details_key_value_pairs = self._table_to_key_value_elements("table#dataset-details")
number_found = name_found = format_found = False
for key, value in dataset_details_key_value_pairs:
print hda
if "Number:" in key.text:
assert str(hda["hid"]) in value.text
number_found = True
if "Name:" in key.text:
assert hda["name"] in value.text
name_found = True
if "Format:" in key.text:
assert hda["extension"] in value.text
format_found = True
assert number_found
assert name_found
assert format_found
def _table_to_key_value_elements(self, table_selector):
tool_parameters_table = self.wait_for_selector_visible(table_selector)
tbody_element = tool_parameters_table.find_element_by_css_selector("tbody")
trs = tbody_element.find_elements_by_css_selector("tr")
assert trs
key_value_pairs = []
for tr in trs:
tds = tr.find_elements_by_css_selector("td")
assert tds
key_value_pairs.append((tds[0], tds[1]))
return key_value_pairs
@selenium_test
def test_rerun(self):
self._run_environment_test_tool()
self.wait_for_history()
hda_id = self.latest_history_item()["id"]
self.hda_click_primary_action_button(hda_id, "rerun")
inttest_div_element = self.tool_parameter_div("inttest")
inttest_input_element = inttest_div_element.find_element_by_css_selector("input")
recorded_val = inttest_input_element.get_attribute("value")
# Assert form re-rendered with correct value in textbox.
assert recorded_val == "42", recorded_val
self.tool_execute()
self.wait_for_history()
new_hda_id = self.latest_history_item()["id"]
assert new_hda_id != hda_id # We do indeed have a new dataset for the re-run
self._check_dataset_details_for_inttest_value(new_hda_id)
@selenium_test
def test_run_data(self):
test_path = self.get_filename("1.fasta")
test_path_decoy = self.get_filename("1.txt")
self.perform_upload(test_path)
self.perform_upload(test_path_decoy)
self.wait_for_history()
self.home()
self.tool_open("head")
self.tool_set_value("input", "1.fasta", expected_type="data")
self.tool_execute()
self.wait_for_history()
latest_hda = self.latest_history_item()
assert latest_hda["hid"] == 3
assert latest_hda["name"] == "Select first on data 1"
def _check_dataset_details_for_inttest_value(self, hda_id, expected_value="42"):
self.hda_click_primary_action_button(hda_id, "info")
with self.main_panel():
self.wait_for_selector_visible("table#dataset-details")
tool_parameters_table = self.wait_for_selector_visible("table#tool-parameters")
tbody_element = tool_parameters_table.find_element_by_css_selector("tbody")
tds = tbody_element.find_elements_by_css_selector("td")
assert tds
assert any([expected_value in td.text for td in tds])
def _run_environment_test_tool(self, inttest_value="42"):
self.home()
self.tool_open("environment_variables")
self.tool_set_value("inttest", inttest_value)
self.tool_execute()