def step_impl(context): driver = context.driver prev_pos = context.caret_position pos = wedutil.caret_pos(driver) assert_equal(prev_pos["top"] - context.scrolled_editor_pane_by, pos["top"])
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)