def step_impl(context, entry_text, field_type, label_name):
    """
    :param entry_text: Text to be entered into the field.
    :param field_type: 'input', 'select', 'textarea', etc.
    :param label_name: What the user sees as the name of the field.
    :type context: behave.runner.Context
    """
    global field_element
    if field_element is None:
        assert False, "Make sure the field labeled " + label_name + " can be found before attempting to enter text"
        # raise
    else:
        field_element.click()
        wait_for_element_load(context.browser, By.CLASS_NAME,
                              "alert-radio-group")
        time.sleep(2)

    try:
        # option_group = context.browser.find_element_by_class_name("alert-radio-group")
        button_list = context.browser.find_elements_by_class_name(
            "alert-radio-button")
    except NoSuchElementException:
        assert False, "Unable to find option group"

    if button_list:
        # Unable to use this because 'option_group' isn't the browser 'select' element
        # Select(option_group).select_by_visible_text(entry_text)
        for button in button_list:
            if entry_text in button.find_element_by_class_name(
                    "alert-radio-label").text:
                button.click()

    time.sleep(2)
Example #2
0
def open_map(context):
    # Find the form element
    try:
        context.form = context.browser.find_element_by_xpath('//form')
    except NoSuchElementException:
        assert False, "Not able to open form"

    try:
        email_wrapper = context.form.find_element_by_name('email')
        email_field = email_wrapper.find_element_by_tag_name('input')
        email_field.send_keys("*****@*****.**")
    except NoSuchElementException:
        assert False, "Not able to open email field"

    try:
        password_wrapper = context.form.find_element_by_name('password')
        password_field = password_wrapper.find_element_by_tag_name('input')
        password_field.send_keys("unchecked")
    except NoSuchElementException:
        assert False, "Not able to open password field"

    context.form.submit()
    wait_for_element_load(context.browser, By.ID, "logout")

    context.browser.execute_script("""location.reload()""")
def logout(browser):
    try:
        browser.find_element_by_id("logout")
    except NoSuchElementException:
        assert False, "Unable to logout"

    find_form(browser).submit()
    wait_for_element_load(browser, By.ID, "login")
def login(context):
    try:
        context.browser.find_element_by_id("login")
    except NoSuchElementException:
        assert False, "Unable to login"

    valid_email_account = "*****@*****.**"
    enter_credentials(context, valid_email_account).submit()
    wait_for_element_load(context.browser, By.ID, "logout")
def step_impl(context, button_name):
    """
    :param button_name: User-visible string on the desired button.
    :type context: behave.runner.Context
    """
    group_name = "form-buttons-row"
    click_named_button_within_named_group(context.browser, group_name,
                                          button_name)
    wait_for_element_load(context.browser, By.CLASS_NAME, "label")
def step_impl(context, button_name):
    """
    :param button_name: User-visible string on the desired button.
    :type context: behave.runner.Context
    """
    group_name = "image-edit"
    click_named_button_within_named_group(context.browser, group_name,
                                          button_name)
    wait_for_element_load(context.browser, By.ID, "image-capture")
    # Bugs me that this is required after having waited for other items on page to be visible.
    time.sleep(0.5)
Example #7
0
def step_impl(context):
    """
    :type context: behave.runner.Context
    """
    # Open the application
    context.browser.get("http://localhost:8100/")
    time.sleep(0.1)

    if context.browser.title == "ClueRide Location Editor":
        wait_for_element_load(context.browser, By.ID, "login")

    if context.browser.title == "info":
        open_map(context)
    else:
        if context.browser.title != "Map":
            print("Expected info page, but found " + context.browser.title);
            assert False, "Unable to reach Login page"

    wait_for_map_loaded(context)
def step_impl(context):
    """
    :type context: behave.runner.Context
    """
    wait_for_element_load(context.browser, By.ID, "logout")
Example #9
0
def wait_for_map_loaded(context):
    wait_for_element_load(context.browser, By.ID, "map")
    wait_for_element_load(context.browser, By.CLASS_NAME, "awesome-marker")