Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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]
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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]
Beispiel #8
0
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)
Beispiel #9
0
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
Beispiel #10
0
def step_impl(context):
    driver = context.driver

    el, _, parent_text = get_element_parent_and_parent_text(driver, ".ref")

    ActionChains(driver)\
        .move_to_element_with_offset(el, 1, 1)\
        .click()\
        .perform()

    assert_true(parent_text.find("A") == -1)
Beispiel #11
0
def step_impl(context):
    driver = context.driver

    el, _, parent_text = get_element_parent_and_parent_text(driver, ".ref")

    ActionChains(driver)\
        .move_to_element_with_offset(el, 1, 1)\
        .click()\
        .perform()

    assert_true(parent_text.find("A") == -1)
Beispiel #12
0
def step_impl(context):
    driver = context.driver

    _, _, parent_text = get_element_parent_and_parent_text(driver, ".ref")

    assert_true(parent_text.find("A") != -1)
Beispiel #13
0
def step_impl(context):
    driver = context.driver

    _, _, parent_text = get_element_parent_and_parent_text(driver, ".ref")

    assert_true(parent_text.find("A") != -1)