def test_click(browser, wait):
    browser.send_inputs('be boundless')
    output_locator = Locator(search_method=SearchMethod.CSS_SELECTOR,
                             search_value='#outputDiv')
    button_locator = Locator(search_method=SearchMethod.CSS_SELECTOR,
                             search_value='#doUpdate')
    output_element = browser.find_element(*output_locator.payload)
    assert not output_element.text
    browser.click(button_locator, wait=wait)
    assert output_element.text == 'be boundless'
Exemple #2
0
def test_click(browser, load_page):
    browser.send_inputs("be boundless")
    output_locator = Locator(search_method=By.CSS_SELECTOR,
                             search_value="#outputDiv")
    button_locator = Locator(search_method=By.CSS_SELECTOR,
                             search_value="#doUpdate")
    output_element = browser.find_element(*output_locator.payload)
    assert not output_element.text
    browser.click(button_locator)
    assert output_element.text == "be boundless"
def test_force_failure(browser):
    browser.get('https://directory.uw.edu', snap=True)
    if not browser.find_elements(By.ID, 'does-not-exist'):
        browser.snap(caption="Manual error capture, but the test continues.",
                     is_error=True)
    browser.wait_for(
        Locator(search_method=By.ID, search_value="does-not-exist"))
class Locators:
    about_the_uw = Locator(search_method=By.ID, search_value='about-the-uw')
def test_locator_defaults():
    locator = Locator(search_method=SearchMethod.CSS_SELECTOR,
                      search_value='foo')
    assert locator.search_value == 'foo'
    assert 'css' in locator.state_description
    assert 'foo' in locator.state_description
    """
    A convenience function for testing the same interactive path under different circumstances.
    :param browser:
    :param capture_delay:
    :return:
    """
    return _fill_in_and_wait(browser,
                             value='be boundless',
                             locator=XPathWithSubstringLocator(
                                 tag='p', displayed_substring='be boundless'),
                             capture_delay=capture_delay)


@pytest.mark.parametrize('locator', [
    XPathWithSubstringLocator(tag='p', displayed_substring='be boundless'),
    Locator(search_method=SearchMethod.CSS_SELECTOR,
            search_value='div#outputDiv'),
    Locator(search_method=SearchMethod.ID, search_value='outputDiv')
])
def test_wait_for(locator, browser):
    element = _fill_in_and_wait(browser, 'be boundless', locator)
    assert element.text == 'be boundless'


def test_wait_for_tag(browser):
    browser.send_inputs('be boundless')
    browser.click_button('update')
    assert browser.wait_for_tag('p', 'be boundless')


def test_context_stops_client_on_exit(url):
    class TestChrome(Chrome):
Exemple #7
0
def test_locator_defaults():
    locator = Locator(search_method=By.CSS_SELECTOR, search_value="foo")
    assert locator.search_value == "foo"
    assert "css" in locator.description
    assert "foo" in locator.description
Exemple #8
0
    :return:
    """
    return _fill_in_and_wait(
        browser,
        value="be boundless",
        locator=XPathWithSubstringLocator(tag="p",
                                          displayed_substring="be boundless"),
        capture_delay=capture_delay,
    )


@pytest.mark.parametrize(
    "locator",
    [
        XPathWithSubstringLocator(tag="p", displayed_substring="be boundless"),
        Locator(search_method=By.CSS_SELECTOR, search_value="div#outputDiv"),
        Locator(search_method=By.ID, search_value="outputDiv"),
    ],
)
def test_wait_for(locator, browser, load_page):
    element = _fill_in_and_wait(browser, "be boundless", locator)
    assert element.text == "be boundless"


def test_wait_for_tag(browser, load_page):
    """Ensure that when wait_for is called using a tag with text, the element is found."""
    browser.send_inputs("be boundless")
    browser.click_button("update")
    assert browser.wait_for_tag("p", "be boundless")