def step_impl(context, what): driver = context.driver util = context.util if what == "an element": what = "the first title element" if what == "the first title element": selector = ".__start_label._title_label" elif what == 'the first paragraph in "body"': selector = ".body .__start_label._p_label" else: raise ValueError("unknown value for what: " + what) element, parent, parent_text = get_element_parent_and_parent_text( driver, selector) ActionChains(driver)\ .click(element) \ .perform() util.send_keys(element, # From the label to before the first letter. [Keys.ARROW_RIGHT] + # This select the whole text of the element. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * len(parent_text) + [Keys.SHIFT]) assert_true(util.is_something_selected(), "something must be selected") text = util.get_selection_text() assert_equal(text, parent_text, "expected selection") context.expected_selection = text context.selection_parent = parent context.caret_screen_position = wedutil.caret_screen_pos(driver)
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): direction = direction.strip() driver = context.driver util = context.util if direction == "": keys = ( # From the label to before the first letter and then past the # first letter. [Keys.ARROW_RIGHT] * 2 + # This moves two caracters to the right with shift down. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * 2 + [Keys.SHIFT]) elif direction == "backwards": keys = ( # From the label to before the first letter and then past the # first letter, and then two more to the right. [Keys.ARROW_RIGHT] * (2 + 2) + # This moves two caracters to the left with shift down. [Keys.SHIFT] + [Keys.ARROW_LEFT] * 2 + [Keys.SHIFT]) else: raise ValueError("unexpected direction: " + direction) element, _, parent_text = get_element_parent_and_parent_text( driver, ".__start_label._title_label") ActionChains(driver)\ .click(element)\ .perform() util.send_keys(element, keys) assert_true(util.is_something_selected(), "something must be selected") context.expected_selection = parent_text[1:3]
def step_impl(context, what): driver = context.driver util = context.util if what == "an element": what = "the first title element" if what == "the first title element": selector = ".__start_label._title_label" elif what == 'the first paragraph in "body"': selector = ".body .__start_label._p_label" else: raise ValueError("unknown value for what: " + what) element, parent, parent_text = get_element_parent_and_parent_text( driver, selector) ActionChains(driver)\ .click(element) \ .perform() util.send_keys( element, # From the label to before the first letter. [Keys.ARROW_RIGHT] + # This select the whole text of the element. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * len(parent_text) + [Keys.SHIFT]) assert_true(util.is_something_selected(), "something must be selected") text = util.get_selection_text() assert_equal(text, parent_text, "expected selection") context.expected_selection = text context.selection_parent = parent context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context): driver = context.driver util = context.util element, parent, _ = get_element_parent_and_parent_text( driver, ".__start_label._title_label") ActionChains(driver)\ .click(element)\ .perform() # On IE, sending the keys to the element itself does not work. send_to = element if driver.name != "internet explorer" else \ util.find_element((By.CSS_SELECTOR, ".wed-document")) util.send_keys(send_to, # From the label to before the first letter and then past # the first letter. [Keys.ARROW_RIGHT] * 3 + # This moves 9 caracters to the right with shift down. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * 9 + [Keys.SHIFT]) assert_true(util.is_something_selected(), "something must be selected") context.selection_parent = parent
def step_impl(context, what): driver = context.driver util = context.util if what == "an element": what = "the first title element" expected_text = None if what == "the first title element": selector = ".__start_label._title_label" elif what == 'the first paragraph in "body"': selector = ".body .__start_label._p_label" elif what == "an attribute": selector = ".body .__start_label._p_label" elif what == 'a readonly element with the text "abc"': selector = ".body ._readonly .__end_label" expected_text = "abc" else: raise ValueError("unknown value for what: " + what) element, parent, length = \ get_element_parent_and_selection_length(driver, selector) ActionChains(driver)\ .click(element) \ .perform() if selector.find("__end_label") != -1: util.send_keys(element, # From the label to after the text [Keys.ARROW_LEFT] + # This select the whole text of the element. [Keys.SHIFT] + [Keys.ARROW_LEFT] * length + [Keys.SHIFT]) else: util.send_keys(element, # From the label to before the first letter. [Keys.ARROW_RIGHT] + # This select the whole text of the element. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * length + [Keys.SHIFT]) assert_true(util.is_something_selected(), "something must be selected") text = util.get_selection_text() if expected_text is not None: assert_equal(text, expected_text) context.expected_selection = text context.selection_parent = parent context.caret_screen_position = wedutil.caret_screen_pos(driver)
def step_impl(context): driver = context.driver util = context.util element = util.find_element((By.CSS_SELECTOR, ".__start_label._title_label")) ActionChains(driver)\ .click(element)\ .perform() # On IE, sending the keys to the element itself does not work. send_to = element if driver.name != "internet explorer" else \ util.find_element((By.CSS_SELECTOR, ".wed-document")) util.send_keys(send_to, # From the label to before the first letter and then past # the first letter. [Keys.ARROW_RIGHT] * 3 + # This moves 9 caracters to the right with shift down. [Keys.SHIFT] + [Keys.ARROW_RIGHT] * 9 + [Keys.SHIFT]) assert_true(util.is_something_selected(), "something must be selected")
def step_impl(context): util = context.util assert_false(util.is_something_selected(), "nothing must be selected")