Example #1
0
def step_impl(context):
    util = context.util
    driver = context.driver
    button = util.find_element(
        (By.CSS_SELECTOR, ".body .__start_label._p_label"))
    ActionChains(driver)\
        .click(button)\
        .send_keys([Keys.ARROW_RIGHT] * 6) \
        .perform()

    context.caret_path = driver.execute_script("""
    var caret = wed_editor.getDataCaret();
    return [wed_editor.data_updater.nodeToPath(caret.node), caret.offset];
    """)

    pos = wedutil.caret_selection_pos(driver)
    # First click away so that the caret is no longer where we left it
    # and the subsequent click moves it again.
    el_pos = util.element_screen_position(button)
    ActionChains(driver) \
        .click(button) \
        .move_to_element_with_offset(button,
                                     pos["left"] - el_pos["left"] + 1,
                                     pos["top"] - el_pos["top"]) \
        .click() \
        .perform()
Example #2
0
File: caret.py Project: nenadg/wed
def step_impl(context):
    util = context.util
    driver = context.driver
    button = util.find_element(
        (By.CSS_SELECTOR, ".body .__start_label._p_label"))
    ActionChains(driver)\
        .click(button)\
        .send_keys([Keys.ARROW_RIGHT] * 6) \
        .perform()

    context.caret_path = driver.execute_script("""
    var caret = wed_editor.getDataCaret();
    return [wed_editor.data_updater.nodeToPath(caret.node), caret.offset];
    """)

    pos = wedutil.caret_selection_pos(driver)
    # First click away so that the caret is no longer where we left it
    # and the subsequent click moves it again.
    el_pos = util.element_screen_position(button)
    ActionChains(driver) \
        .click(button) \
        .move_to_element_with_offset(button,
                                     pos["left"] - el_pos["left"] + 1,
                                     pos["top"] - el_pos["top"]) \
        .click() \
        .perform()
Example #3
0
def step_impl(context):
    util = context.util

    menu = util.find_element((By.CLASS_NAME, "wed-context-menu"))
    # The click was in the middle of the trigger.
    trigger = context.context_menu_trigger
    target = trigger.location
    size = trigger.size  # Read just once = 1 network roundtrip.
    target["left"] += size["width"] / 2
    target["top"] += size["height"] / 2
    assert_equal(selenic.util.locations_within(
        util.element_screen_position(menu), target, 10), '')
Example #4
0
def step_impl(context):
    util = context.util

    menu = util.find_element((By.CLASS_NAME, "wed-context-menu"))
    # The click was in the middle of the trigger.
    trigger = context.context_menu_trigger
    target = trigger.location
    size = trigger.size  # Read just once = 1 network roundtrip.
    target["left"] += size["width"] / 2
    target["top"] += size["height"] / 2
    assert_equal(
        selenic.util.locations_within(util.element_screen_position(menu),
                                      target, 10), '')
Example #5
0
def step_impl(context):
    util = context.util

    # Yep, we must use the dropdown-menu for this.
    menu = util.find_element(
        (By.CSS_SELECTOR, ".wed-context-menu>.dropdown-menu"))
    assert_true(util.completely_visible_to_user(menu),
                "menu is completely visible")

    # This is a check that without the adjustment made to show the
    # whole menu, the menu would overflow outside the editing pane. (A
    # freakishly small menu would not overflow, for instance, and we
    # would not be testing what we think we are testing.)
    gui_root = wedutil.gui_root(util)
    assert_true(
        context.context_menu_trigger.location["left"] -
        util.element_screen_position(gui_root)["left"] + menu.size["width"] >
        gui_root.size["width"], "the menu would otherwise overflow")
Example #6
0
def step_impl(context):
    util = context.util

    # Yep, we must use the dropdown-menu for this.
    menu = util.find_element((By.CSS_SELECTOR,
                              ".wed-context-menu>.dropdown-menu"))
    assert_true(util.completely_visible_to_user(menu),
                "menu is completely visible")

    # This is a check that without the adjustment made to show the
    # whole menu, the menu would overflow outside the editing pane. (A
    # freakishly small menu would not overflow, for instance, and we
    # would not be testing what we think we are testing.)
    gui_root = wedutil.gui_root(util)
    assert_true(context.context_menu_trigger.location["left"] -
                util.element_screen_position(gui_root)["left"] +
                menu.size["width"] > gui_root.size["width"],
                "the menu would otherwise overflow")