def step_impl(context): driver = context.driver util = context.util element, parent, parent_text = get_element_parent_and_parent_text( driver, ".__start_label._title_label") # This is where our selection will end end = util.element_screen_center(element) end["left"] += 2 # Move it off-center for this test element.click() wedutil.wait_for_caret_to_be_in(util, parent) # From the label to before the first letter and then past the # first letter. ActionChains(driver)\ .send_keys(*[Keys.ARROW_RIGHT] * 2)\ .perform() # We need to get the location of the caret. start = wedutil.caret_selection_pos(driver) select_text(context, start, end) assert_true(util.is_something_selected(), "something must be selected") context.expected_selection = parent_text[0:1] context.selection_parent = parent context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context, direction): driver = context.driver util = context.util direction = direction.strip() element, parent, parent_text = get_element_parent_and_parent_text( driver, ".__start_label._title_label") element.click() wedutil.wait_for_caret_to_be_in(util, parent) # From the label to before the first letter and then past the # first letter. ActionChains(driver)\ .send_keys(*[Keys.ARROW_RIGHT] * 2)\ .perform() # We need to get the location of the caret. start = wedutil.caret_selection_pos(driver) # This moves two characters to the right ActionChains(driver)\ .send_keys(*[Keys.ARROW_RIGHT] * 2)\ .perform() end = wedutil.caret_selection_pos(driver) if direction == "": select_text(context, start, end) elif direction == "backwards": select_text(context, end, start) else: raise ValueError("unexpected direction: " + direction) context.expected_selection = parent_text[1:3] context.selection_parent = parent context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context): util = context.util sfs = util.find_elements((By.CSS_SELECTOR, r".btw\:sf")) ActionChains(context.driver) \ .move_to_element_with_offset(sfs[1], 1, 2) \ .click() \ .perform() wedutil.wait_for_caret_to_be_in(util, sfs[1])
def step_impl(context, order, what): driver = context.driver util = context.util position = ORDER_TO_POS[order] el = driver.find_elements_by_css_selector("." + what)[position] wedutil.wait_for_caret_to_be_in(util, el)
def step_impl(context, text): driver = context.driver util = context.util element = util.find_clickable_element((By.CLASS_NAME, "title")) element.click() wedutil.wait_for_caret_to_be_in(util, element) context.element_to_test_for_text = element assert_true( util.get_text_excluding_children(element).find(text) == -1)
def step_impl(context, text): driver = context.driver util = context.util element = util.find_clickable_element((By.CLASS_NAME, "title")) ActionChains(driver) \ .click(element) \ .perform() wedutil.wait_for_caret_to_be_in(util, element) context.element_to_test_for_text = element assert_true(util.get_text_excluding_children(element).find(text) == -1) context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context, text): driver = context.driver util = context.util element = util.find_clickable_element((By.CLASS_NAME, "title")) ActionChains(driver) \ .click(element) \ .perform() wedutil.wait_for_caret_to_be_in(util, element) context.element_to_test_for_text = element assert_true( util.get_text_excluding_children(element).find(text) == -1) context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context, kind): util = context.util driver = context.driver element = util.find_element((By.CSS_SELECTOR, ".title")) ActionChains(driver) \ .click(element) \ .perform() wedutil.wait_for_caret_to_be_in(util, element) context.execute_steps(u""" When the user uses the keyboard to bring up the context menu Then a context menu is visible close to where the user invoked it When the user clicks the choice named "Test {0}" """.format(kind))
def step_impl(context, direction): driver = context.driver util = context.util direction = direction.strip() element = util.find_element((By.CSS_SELECTOR, "._start_button._title_label")) parent = element.find_element_by_xpath("..") element.click() wedutil.wait_for_caret_to_be_in(util, parent) # From the label to before the first letter and then past the # first letter. ActionChains(driver)\ .send_keys(*[Keys.ARROW_RIGHT] * 3)\ .perform() # We need to get the location of the caret. start = wedutil.caret_selection_pos(driver) # This moves two characters to the right ActionChains(driver)\ .send_keys(*[Keys.ARROW_RIGHT] * 2)\ .perform() end = wedutil.caret_selection_pos(driver) if direction == "": wedutil.select_text(driver, start, end) elif direction == "backwards": wedutil.select_text(driver, end, start) else: raise ValueError("unexpected direction: " + direction) text = util.get_text_excluding_children(parent) context.expected_selection = text[1:3] context.selection_parent = parent context.caret_position = wedutil.caret_pos(driver)
def step_impl(context): util = context.util button = context.clicked_element en = button.find_element_by_class_name("_element_name") wedutil.wait_for_caret_to_be_in(util, en)