tor-browser

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

test_1902464_workhub_transcribeme_com.py (1706B)


      1 import pytest
      2 
      3 URL = "https://workhub.transcribeme.com/Exam"
      4 
      5 CAPTCHA_CSS = "re-captcha"
      6 USERNAME_CSS = "input[name=username]"
      7 PASSWORD_CSS = "input[name=password]"
      8 EXPIRED_CSS = "app-renewpassword"
      9 SIGN_IN_CSS = "#btn-login"
     10 UNSUPPORTED_CSS = "#chromeOnlyPopup"
     11 
     12 
     13 async def does_unsupported_popup_appear(client, credentials):
     14    await client.navigate(URL)
     15 
     16    username = client.await_css(USERNAME_CSS)
     17    password = client.find_css(PASSWORD_CSS)
     18    sign_in = client.find_css(SIGN_IN_CSS)
     19    assert client.is_displayed(username)
     20    assert client.is_displayed(password)
     21    assert client.is_displayed(sign_in)
     22 
     23    username.send_keys(credentials["username"])
     24    password.send_keys(credentials["password"])
     25    sign_in.click()
     26 
     27    for _ in range(10):
     28        captcha, unsupported, expired = client.await_first_element_of([
     29            client.css(CAPTCHA_CSS),
     30            client.css(UNSUPPORTED_CSS),
     31            client.css(EXPIRED_CSS),
     32        ])
     33        if captcha:
     34            print("\a")  # beep to let the user know to do the captcha
     35            client.await_element_hidden(client.css(CAPTCHA_CSS), timeout=90)
     36        else:
     37            break
     38    if expired:
     39        pytest.skip("Your password has expired. Please visit the site and renew it.")
     40        return
     41 
     42    await client.stall(1)
     43    return client.find_css(UNSUPPORTED_CSS, is_displayed=True)
     44 
     45 
     46 @pytest.mark.asyncio
     47 @pytest.mark.with_interventions
     48 async def test_enabled(client, credentials):
     49    assert not await does_unsupported_popup_appear(client, credentials)
     50 
     51 
     52 @pytest.mark.asyncio
     53 @pytest.mark.without_interventions
     54 async def test_disabled(client, credentials):
     55    assert await does_unsupported_popup_appear(client, credentials)