diff --git a/src/e2e_tests/common/pages.py b/src/e2e_tests/common/pages.py index 4b0c1b13..880852d3 100644 --- a/src/e2e_tests/common/pages.py +++ b/src/e2e_tests/common/pages.py @@ -2,6 +2,7 @@ from abc import ABC import conftest import random +import pytest from selenium.common.exceptions import ElementNotInteractableException, NoSuchElementException, StaleElementReferenceException, TimeoutException from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver @@ -85,6 +86,11 @@ def load(self): def all_script_links(self): return self.browser.find_elements_by_css_selector("a.collection-item.script-list-item") + @property + def all_groups(self): + + return self.browser.find_elements_by_css_selector("div.script-list-group a span") + def get_script_link_by_name(self, name): try: return self.browser.find_element_by_link_text(name) @@ -147,7 +153,15 @@ def sidebar_history_button(self): @property def sidebar_search_button(self): - return self.find_element(".main-app-sidebar .search-button") + return self.find_element(".main-app-sidebar .search-button[alt=\"Search script\"]") + + @property + def sidebar_clear_search_button(self): + return self.find_element(".main-app-sidebar .search-button[alt=\"Clear search\"]") + + @property + def sidebar_search_input(self): + return self.find_element("input.search-field") @property def sidebar_header_link(self): @@ -201,6 +215,20 @@ def active_executor_tab(self): def add_new_tab_button(self): return self.find_element(".tab [title='Add another script instance']") + @property + def history_table(self): + return self.find_element("div.executions-log-table tr") + + @property + def history_table_column_titles(self): + return ["ID", "Start Time", "User", "Script", "Status"] + + def find_history_column_by_name(self, name): + try: + return self.browser.find_element_by_xpath("//th[contains(text(), \"{}\")]".format(name)) + except NoSuchElementException: + return None + class VeryParametrizedScript(Page): browser: RemoteWebDriver @@ -246,6 +274,18 @@ def parameter_file_upload(self): def parameter_multiple_selection(self): return self.find_input_by_label('Multiple selection') + @property + def parameter_multiple_selection_drop_down(self): + return self.find_element('ul.dropdown-content.select-dropdown.multiple-select-dropdown', get_parent_element(self.parameter_multiple_selection)) + + @property + def parameter_multiple_selection_drop_down_checked_elements(self): + return self.parameter_multiple_selection_drop_down.find_elements_by_css_selector('li.selected:not([class*=\"disabled\"])') + + @property + def parameter_multiple_selection_drop_down_unchecked_elements(self): + return self.parameter_multiple_selection_drop_down.find_elements_by_css_selector('li:not([class*=\"selected\"]):not([class*=\"disabled\"])') + @property def parameter_required_text(self): return self.find_input_by_label('Required Text') diff --git a/src/e2e_tests/general/test_history_empty.py b/src/e2e_tests/general/test_history_empty.py new file mode 100644 index 00000000..a12cf290 --- /dev/null +++ b/src/e2e_tests/general/test_history_empty.py @@ -0,0 +1,31 @@ +from common.pages import Page +import allure +from common.pages import is_displayed, is_enabled, is_disabled +from delayed_assert import expect, assert_expectations +from allure import severity, severity_level + + +@severity(severity_level.CRITICAL) +@allure.title("Check history page is opened by click on button on home page") +def test_history_page_is_opened_on_click(browser, config_host): + home_page = Page(browser, config_host) + home_page.load() + + home_page.sidebar_history_button.click() + + expect(home_page.browser.current_url == config_host + "index.html#/history") + + assert_expectations() + + +@severity(severity_level.CRITICAL) +@allure.title("Check presented elements on history page") +def test_history_page(browser, config_host): + home_page = Page(browser, config_host) + + expect(not is_displayed(home_page.main_app_content), "App content is found on history page") + expect(is_displayed(home_page.history_table), "History table not found ") + for column in home_page.history_table_column_titles: + expect(is_displayed(home_page.find_history_column_by_name(column)), "\"{}\" not found".format(column)) + + assert_expectations() diff --git a/src/e2e_tests/general/test_main_page.py b/src/e2e_tests/general/test_main_page.py index 56843451..b64b13f4 100644 --- a/src/e2e_tests/general/test_main_page.py +++ b/src/e2e_tests/general/test_main_page.py @@ -15,7 +15,6 @@ def test_home_page(browser, config_host): expect(is_displayed(home_page.sidebar_header), "Header on sidebar not found") expect(is_displayed(home_page.sidebar_history_button), "History button on sidebar not found") expect(is_displayed(home_page.sidebar_scripts_list), "Scripts list not found") - expect(is_displayed(home_page.sidebar_search_button), "Search button not found") expect(is_displayed(home_page.sidebar_header_link), "Header link not found") expect(not is_displayed(home_page.main_app_content), "App content is displayed") @@ -51,3 +50,26 @@ def test_app_content(browser, config_host): assert_expectations() +@severity(severity_level.CRITICAL) +@allure.title("Check appeared and hidden search elements by default") +def test_search_elements_by_default(browser, config_host): + home_page = Page(browser, config_host) + + expect(is_displayed(home_page.sidebar_search_button), "Search button not found") + expect(not is_displayed(home_page.sidebar_clear_search_button), "Clear search button is displayed") + expect(not is_displayed(home_page.sidebar_search_input), "Search input field is displayed") + + assert_expectations() + + +@severity(severity_level.CRITICAL) +@allure.title("Check appeared and hidden search elements after search button click") +def test_search_elements_after_click(browser, config_host): + home_page = Page(browser, config_host) + home_page.sidebar_search_button.click() + + expect(not is_displayed(home_page.sidebar_search_button), "Search button is displayed after click") + expect(is_displayed(home_page.sidebar_clear_search_button), "Clear search button not found after click") + expect(is_displayed(home_page.sidebar_search_input), "Search input field not found after click") + + assert_expectations() diff --git a/src/e2e_tests/sample_scripts/test_search.py b/src/e2e_tests/sample_scripts/test_search.py new file mode 100644 index 00000000..8571c416 --- /dev/null +++ b/src/e2e_tests/sample_scripts/test_search.py @@ -0,0 +1,36 @@ +from common.pages import Page +import allure +from common.pages import is_displayed +from delayed_assert import expect, assert_expectations +from allure import severity, severity_level + +search_request = "wor" + + +@severity(severity_level.NORMAL) +@allure.title("Check search results") +def test_search_by_fixed_keyword_case_insensitive(browser, config_host, scripts): + home_page = Page(browser, config_host) + home_page.load() + + home_page.sidebar_search_button.click() + home_page.sidebar_search_input.send_keys(search_request) + + displayed_results = home_page.all_script_links + home_page.all_groups + + for result in displayed_results: + expect(str(result.text).find(search_request) > -1, "\"{}\" containts no search request \"{}\" but still listed after search".format(str(result.text), search_request)) + + assert_expectations() + + +@severity(severity_level.NORMAL) +@allure.title("Check clear search, check all scripts are back") +def test_clear_search(browser, config_host, scripts): + home_page = Page(browser, config_host) + home_page.sidebar_clear_search_button.click() + + for required_script in scripts: + expect(is_displayed(home_page.get_script_link_by_name(required_script)), "Script by name \"{}\" not found after search".format(required_script)) + + assert_expectations() diff --git a/src/e2e_tests/sample_scripts/test_very_parametrized_script.py b/src/e2e_tests/sample_scripts/test_very_parametrized_script.py index 9903920d..dd78aab1 100644 --- a/src/e2e_tests/sample_scripts/test_very_parametrized_script.py +++ b/src/e2e_tests/sample_scripts/test_very_parametrized_script.py @@ -7,6 +7,7 @@ import random import sys from selenium.webdriver.common.keys import Keys +import time search_request = "lo" @@ -253,3 +254,34 @@ def test_check_search_results_in_command_based_list(browser, config_host): expect(str(element.text).find(search_request) > -1) assert_expectations() + + +@severity(severity_level.NORMAL) +@allure.title("Check Multiple selection") +def test_check_multiple_selection(browser, config_host): + very_parametrized_script_page = VeryParametrizedScript(browser, config_host) + very_parametrized_script_page.parameter_multiple_selection.click() + + expect(is_displayed(very_parametrized_script_page.parameter_multiple_selection_drop_down), "Drop down for Multiple selection not found after click") + assert_expectations() + + +@severity(severity_level.NORMAL) +@allure.title("Check Multiple selection check/uncheck action") +def test_check_multiple_selection_check_uncheck_action(browser, config_host): + very_parametrized_script_page = VeryParametrizedScript(browser, config_host) + + if len(very_parametrized_script_page.parameter_multiple_selection_drop_down_checked_elements) > 0: + random_option = random.choice(very_parametrized_script_page.parameter_multiple_selection_drop_down_checked_elements) + random_option.click() + expect("selected" not in random_option.get_attribute("class").split(" "), "Checked options stays selected after click on it") + random_option.click() + expect("selected" in random_option.get_attribute("class").split(" "), "Unchecked options stays not selected after click on it") + if len(very_parametrized_script_page.parameter_multiple_selection_drop_down_unchecked_elements) > 0: + random_option = random.choice(very_parametrized_script_page.parameter_multiple_selection_drop_down_unchecked_elements) + random_option.click() + expect("selected" in random_option.get_attribute("class").split(" "), "Unchecked options stays not selected after click on it") + random_option.click() + expect("selected" not in random_option.get_attribute("class").split(" "), "Checked options stays selected after click on it") + + assert_expectations() \ No newline at end of file