def header_menu_button_style(selenium_generics: SeleniumGenerics, locators: Locators, locator_path, data_table): xpath = locators.parse_and_get(locator_path) selenium_generics.validate_element_style(xpath, data_table)
def check_css_property_is_not(attribute, selenium_generics: SeleniumGenerics, locators: Locators, locator_path, value): actual_value = selenium_generics.get_css_attribute_of_element(locators.parse_and_get(locator_path), attribute) assert_that(actual_value).is_not_equal_to(value)
def element_not_exists(selenium, locators: Locators, locator_path): CustomWait(selenium).wait_for_element_not_visible(value=locators.parse_and_get(locator_path))
def set_add_element_value(selenium, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) element.clear()
def does_not_contain_text(selenium_generics: SeleniumGenerics, locators: Locators, locator_path, text): actual_text = selenium_generics.get_text_from_element(locators.parse_and_get(locator_path)) assert_that(actual_text).does_not_contain(text)
def dbl_click_element(selenium, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) ActionChains(selenium).double_click(element).perform()
def add_element_value(selenium, text, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) actual_text = element.get_attribute('value') element.send_keys(actual_text + text)
def element_not_displayed(selenium, locators: Locators, locator_path): assert_that(selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)).is_displayed()).is_false()
def wait_for_displayed(selenium, locators: Locators, locator_path): CustomWait(selenium).wait_for_element_visible(value=locators.parse_and_get(locator_path))
def check_element_enabled(selenium, locators: Locators, locator_path): locator = locators.parse_and_get(locator_path) CustomWait(selenium).wait_for_element_visible(value=locator) assert_that(selenium.find_element(By.XPATH, locator).is_enabled()).is_true()
def check_element_not_exists(selenium, locators: Locators, locator_path, occurrence_count): locator = locators.parse_and_get(locator_path) assert_that(selenium.find_elements(By.XPATH, locator).__len__()).is_not_equal_to(occurrence_count)
def hover_over_shadow_element(selenium_generics: SeleniumGenerics, locators: Locators, element_path): parent_xpath = locators.parse_and_get(element_path['parent_xpath']) locator_paths = [ locators.parse_and_get(path) for path in element_path['shadow_path'].split(' ~ ') ] selenium_generics.shadow_hover(parent_xpath, *locator_paths)
def hover_over_element(selenium_generics: SeleniumGenerics, locators: Locators, locator_path): xpath = locators.parse_and_get(locator_path) selenium_generics.scroll_into_view(selector=xpath) selenium_generics.hover(selector=xpath)
def click_on_element(selenium_generics: SeleniumGenerics, locators: Locators, locator_path): xpath = locators.parse_and_get(locator_path) selenium_generics.scroll_into_view(selector=xpath) selenium_generics.click(selector=xpath)
def move_to_element_by_offset(selenium, locators: Locators, locator_path, x, y): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) ActionChains(selenium).move_to_element_with_offset(element, int(x), int(y))
def check_within_viewport(selenium, locators: Locators, locator_path): assert_that(selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)).is_in_viewport()).is_false()
def click_element(selenium, locators: Locators, locator_path): selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)).click()
def check_is_existing(selenium, locators: Locators, locator_path): CustomWait(selenium).wait_for_element_present(value=locators.parse_and_get(locator_path))
def js_click_element(selenium, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) selenium.execute_script('arguments[0].click();', element)
def check_does_not_contain_same_text(selenium_generics: SeleniumGenerics, locators: Locators, locator_path1, locator_path2): actual_text1 = selenium_generics.get_text_from_element(locators.parse_and_get(locator_path1)) actual_text2 = selenium_generics.get_text_from_element(locators.parse_and_get(locator_path2)) assert_that(actual_text1).is_not_equal_to(actual_text2)
def set_element_value(selenium, text, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) element.send_keys(text)
def scroll_to_element(selenium, locators: Locators, locator_path): element = selenium.find_element(By.XPATH, locators.parse_and_get(locator_path)) script = 'arguments[0].scrollIntoView({block: "center", inline: "center"})' selenium.execute_script(script, element)
def drag_and_drop_element(selenium, locators: Locators, source, target): source_elem = selenium.find_element(By.XPATH, locators.parse_and_get(source)) target_elem = selenium.find_element(By.XPATH, locators.parse_and_get(target)) action = ActionChains(selenium) action.drag_and_drop(source_elem, target_elem).perform()
def select_option_by_value(selenium, option, locators: Locators, locator_path): select = Select(selenium.find_element(By.XPATH, locators.parse_and_get(locator_path))) select.select_by_value(option)
def contains_any_text(selenium_generics: SeleniumGenerics, locators: Locators, locator_path): actual_text = selenium_generics.get_text_from_element(locators.parse_and_get(locator_path)) assert_that(actual_text).matches(r'(.*?)')
def deselect_option_index(selenium, index: int, locators: Locators, locator_path): select = Select(selenium.find_element(By.XPATH, locators.parse_and_get(locator_path))) select.deselect_by_index(index)
def element_not_selected(selenium, locators: Locators, locator_path): locator = locators.parse_and_get(locator_path) CustomWait(selenium).wait_for_element_visible(value=locator) assert_that(selenium.find_element(By.XPATH, locator).is_selected()).is_false()
def deselect_option_by_visible_text(selenium, option, locators: Locators, locator_path): select = Select(selenium.find_element(By.XPATH, locators.parse_and_get(locator_path))) select.deselect_by_visible_text(option)
def element_not_equals_text(selenium_generics: SeleniumGenerics, locators: Locators, locator_path, text): actual_text = selenium_generics.get_text_from_element(locators.parse_and_get(locator_path)) assert_that(actual_text).is_not_equal_to(text)
def element_text(selenium_generics: SeleniumGenerics, locators: Locators, locator_path, expected_text): xpath = locators.parse_and_get(locator_path) selenium_generics.validate_element_text(xpath, expected_text)