tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_1856915_login_yahoo_com.py (1797B)


      1 import pytest
      2 from webdriver.error import NoSuchElementException
      3 
      4 URL = "https://login.yahoo.com/"
      5 USERNAME_CSS = "#login-username"
      6 SIGNIN_CSS = "#login-signin"
      7 TOGGLE_CSS = "#password-toggle-button"
      8 RECAPTCHA_CSS = "#recaptcha-challenge"
      9 
     10 
     11 async def is_password_reveal_toggle_fully_visible(client, in_headless_mode):
     12    if in_headless_mode:
     13        pytest.xfail("Skipping as cannot do reCAPTCHA in headless mode.")
     14        return False
     15    await client.navigate(URL)
     16    client.await_css(USERNAME_CSS).send_keys("webcompat")
     17    client.await_css(SIGNIN_CSS).click()
     18    recaptcha, toggle = client.await_first_element_of(
     19        [
     20            client.css(RECAPTCHA_CSS),
     21            client.css(TOGGLE_CSS),
     22        ],
     23        is_displayed=True,
     24    )
     25    if recaptcha:
     26        client.await_css(RECAPTCHA_CSS, is_displayed=True)
     27        print("\a")  # beep to let the user know to do the reCAPTCHA
     28        try:
     29            toggle = client.await_css(TOGGLE_CSS, timeout=60)
     30        except NoSuchElementException:
     31            pytest.xfail(
     32                "Timed out waiting for reCAPTCHA to be completed. Please try again."
     33            )
     34            return False
     35    return client.execute_script(
     36        """
     37        const toggle = arguments[0].getBoundingClientRect();
     38        return toggle.width >= 16;
     39    """,
     40        toggle,
     41    )
     42 
     43 
     44 @pytest.mark.only_platforms("android")
     45 @pytest.mark.asyncio
     46 @pytest.mark.with_interventions
     47 async def test_enabled(client, in_headless_mode):
     48    assert await is_password_reveal_toggle_fully_visible(client, in_headless_mode)
     49 
     50 
     51 @pytest.mark.only_platforms("android")
     52 @pytest.mark.asyncio
     53 @pytest.mark.without_interventions
     54 async def test_disabled(client, in_headless_mode):
     55    assert not await is_password_reveal_toggle_fully_visible(client, in_headless_mode)