-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
@property | ||
def history_table_column_titles(self): | ||
return ["ID", "Start Time", "User", "Script", "Status"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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') | ||
|
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() |
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you are working with predefined scripts, I think this |
||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() |
There was a problem hiding this comment.
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