Ejemplo n.º 1
0
def test(browser, request):
    page = HelloPage(browser, url)

    assert page.greeting.text == "Hello anonymous"
    assert page.address.text == "You are in the middle of f*****g nowhere"

    page.name_input.clear()
    page.address_input.clear()
    page.name_input.send_keys("Alex")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello Alex"
    assert page.address.text == "You are in the middle of f*****g nowhere"
    assert page.name_input.get_attribute("value") == "Alex"

    page.name_input.clear()
    page.address_input.clear()
    page.address_input.send_keys("localhost")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello anonymous"
    assert page.address.text == "You are in localhost"
    assert page.address_input.get_attribute("value") == "localhost"

    page.name_input.clear()
    page.address_input.clear()
    page.name_input.send_keys("Alex")
    page.address_input.send_keys("localhost")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello Alex"
    assert page.address.text == "You are in localhost"
    assert page.name_input.get_attribute("value") == "Alex"
    assert page.address_input.get_attribute("value") == "localhost"
Ejemplo n.º 2
0
def test_post(browser, request):
    name = "USER"
    age = 10
    year = date.today().year - age

    anon_on_page = "Hello anonymous!"
    name_on_page = f"Hello {name}"
    year_on_page = f"You was born at {year}!"

    page = HelloPage(browser, url)

    validate_structure(page)
    validate_content(page, anon_on_page)

    set_input_name_value(page, name)
    set_input_age_value(page, "")
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)

    set_input_name_value(page, "")
    set_input_age_value(page, str(age))
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)

    set_input_name_value(page, name)
    set_input_age_value(page, str(age))
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, name_on_page, year_on_page)

    reset(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)
Ejemplo n.º 3
0
def test(browser, request):
    page = HelloPage(browser, url)

    assert page.greeting.text == "Hello, Anon!"
    assert page.address.text == "Your location is XZ."

    page.name_input.clear()
    page.address_input.clear()
    page.name_input.send_keys("Mike")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello, Mike!"
    assert page.address.text == "Your location is XZ."
    # assert page.name_input.get_attribute("value") == "Mike"

    page.name_input.clear()
    page.address_input.clear()
    page.address_input.send_keys("localhost")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello, Anon!"
    assert page.address.text == "Your location is localhost."
    # assert page.address_input.get_attribute("value") == "localhost"

    page.name_input.clear()
    page.address_input.clear()
    page.name_input.send_keys("Mike")
    page.address_input.send_keys("localhost")
    page.submit_button.click()
    validate_redirect(page, url)
    assert page.greeting.text == "Hello, Mike!"
    assert page.address.text == "Your location is localhost."
Ejemplo n.º 4
0
def test_post(browser, request):
    name = "USER"
    age = 10
    year = date.today().year - age
    if year >= 0:
        era = "AC"
    elif year < 0:
        era = "BC"
        year = -year
    anon_on_page = "Hello anonymous!"
    name_on_page = f"Hello {name}"
    year_on_page = f"You were born in {year} {era}!"

    page = HelloPage(browser, url)

    validate_structure(page)
    validate_content(page, anon_on_page)

    set_input_name_value(page, name)
    set_input_age_value(page, "")
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)

    set_input_name_value(page, "")
    set_input_age_value(page, str(age))
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)

    set_input_name_value(page, name)
    set_input_age_value(page, str(age))
    submit(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, name_on_page, year_on_page)

    reset(page)
    validate_redirect(page, fr"hello/?")
    validate_content(page, anon_on_page)
Ejemplo n.º 5
0
def test_get(browser, request):
    page = HelloPage(browser, url)

    validate_title(page)
    validate_structure(page)
    validate_content(page, "Hello anonymous")