tor-browser

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

test_1899048_datanyze_com.py (1440B)


      1 import pytest
      2 
      3 URL = "https://www.datanyze.com/companies/alodokter/399453377"
      4 
      5 # The site ends up showing us different captchas for the failure
      6 # case and the case when its bot-detection has been triggered,
      7 # so we can still write a test, but it may not always run successfully.
      8 
      9 CAPTCHA_CSS = ".main-wrapper .zone-name-title"
     10 SUPPORTED_CSS = "app-company"
     11 UNSUPPORTED_CSS = "#px-captcha-wrapper"
     12 
     13 
     14 async def visit_site(client):
     15    await client.make_preload_script("delete navigator.__proto__.webdriver")
     16    await client.navigate(URL, wait="none")
     17    _, _, captcha = client.await_first_element_of(
     18        [
     19            client.css(SUPPORTED_CSS),
     20            client.css(UNSUPPORTED_CSS),
     21            client.css(CAPTCHA_CSS),
     22        ],
     23        is_displayed=True,
     24    )
     25    if captcha:
     26        pytest.skip("Site presented an infinite captcha; please test manually")
     27 
     28 
     29 @pytest.mark.skip_platforms("android")
     30 @pytest.mark.asyncio
     31 @pytest.mark.with_interventions
     32 async def test_enabled(client):
     33    await visit_site(client)
     34    assert client.await_css(SUPPORTED_CSS, is_displayed=True)
     35    assert not client.find_css(UNSUPPORTED_CSS, is_displayed=True)
     36 
     37 
     38 @pytest.mark.skip_platforms("android")
     39 @pytest.mark.asyncio
     40 @pytest.mark.without_interventions
     41 async def test_disabled(client):
     42    await visit_site(client)
     43    assert client.await_css(UNSUPPORTED_CSS, is_displayed=True)
     44    assert not client.find_css(SUPPORTED_CSS, is_displayed=True)