def sign_in(browser: WebDriverT, credentials: Credentials) -> None:
    current_url = browser.current_url

    try:
        page = SignInPage(browser, f"{URL_SIGN_IN}?next={current_url}")

        page.password = credentials.password = credentials.password
        page.username = credentials.username = credentials.username

        page.sign_in.click()

        validate_redirect(page, current_url)

    finally:
        browser.get(current_url)

    validate_redirect(page, current_url)
def test(browser, request):
    page = HelloPage(browser, url)

    assert page.greeting.text == "Hello anonymous"
    assert page.address.text == "You are in 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 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"
def sign_up(browser: WebDriverT) -> Credentials:
    current_url = browser.current_url
    credentials = Credentials()

    try:
        page = SignUpPage(browser, URL_SIGN_UP)

        nonce = os.urandom(8).hex()

        page.email = credentials.email = f"test_email_{nonce}@test.com"
        page.password = credentials.password = f"Password_{nonce}_123+"
        page.password_confirmation = credentials.password
        page.username = credentials.username = f"test_user_{nonce}"

        page.sign_up.click()

        validate_redirect(page, URL_LANDING)

    finally:
        browser.get(current_url)

    validate_redirect(page, current_url)

    return credentials
def wipe_posts(page: AllPostsPage):
    page.wipe.click()
    validate_redirect(page, URL_BLOG)
def delete_post(page: AllPostsPage, post: WebElement) -> None:
    delete = get_delete_button(post)
    delete.click()
    validate_redirect(page, URL_BLOG)
def create_post(page: AllPostsPage, content: str) -> None:
    page.content = content
    page.tell.click()
    validate_redirect(page, URL_BLOG)