async def login_home(browser, app, username):
    """Visit login page, login, go home

    A good way to start a session
    """
    login_url = url_concat(
        url_path_join(public_url(app), "hub/login"),
        {"next": ujoin(app.hub.base_url, "home")},
    )
    await browser.goto(login_url)
    async with browser.expect_navigation(url=re.compile(".*/hub/home")):
        await login(browser, username)
Visit login page, login, go home

A good way to start a session
jupyterhub/tests/browser/test_browser.py