Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added search and history tests #451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/e2e_tests/common/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the empty line

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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you return "tr" as a "history table" ? tr is only a single row
Please either remove the tr from here or rename the method name


@property
def history_table_column_titles(self):
return ["ID", "Start Time", "User", "Script", "Status"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be a constant?


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
Expand Down Expand Up @@ -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')
Expand Down
31 changes: 31 additions & 0 deletions src/e2e_tests/general/test_history_empty.py
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 23 additions & 1 deletion src/e2e_tests/general/test_main_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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()
36 changes: 36 additions & 0 deletions src/e2e_tests/sample_scripts/test_search.py
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace the variable with the string literal, it makes the test easier to read


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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are working with a predefined set of scripts, I think it would be more transparent to verify, that "display_result" is equal to an array of some elements


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()
32 changes: 32 additions & 0 deletions src/e2e_tests/sample_scripts/test_very_parametrized_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import random
import sys
from selenium.webdriver.common.keys import Keys
import time

search_request = "lo"

Expand Down Expand Up @@ -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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this test? It would be covered by the next test anyway

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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are working with predefined scripts, I think this if is redundant here. You should know what to expect there.

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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a blank line before this if

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()