tor-browser

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

test_1947105_pexels_com.py (1403B)


      1 import pytest
      2 
      3 URL = "https://www.pexels.com/photo/stylish-woman-relaxing-outdoors-in-autumn-fashion-29946756/"
      4 
      5 FREE_DOWNLOAD_BUTTON_CSS = (
      6    "a[class*=Button][href*='dl=pexels-ekoagalarov-29946756.jpg']"
      7 )
      8 POPUP_CSS = ".ReactModal__Content[class*=after-open]"
      9 
     10 
     11 async def check_popup(client, should_be_offscreen):
     12    # The issue is intermittent, so we run the test up to 10 times to be relatively confident.
     13    # If the popup is never offscreen with the intervention on, we pass that check.
     14    # If the popup is offscreen even once without the intervention, we pass that check.
     15    for _ in range(10):
     16        await client.navigate(URL)
     17        client.soft_click(client.await_css(FREE_DOWNLOAD_BUTTON_CSS, is_displayed=True))
     18        popup = client.await_css(POPUP_CSS, is_displayed=True)
     19        is_off = client.execute_script(
     20            """
     21            return arguments[0].getBoundingClientRect().top < 0;
     22          """,
     23            popup,
     24        )
     25        if should_be_offscreen and is_off:
     26            return True
     27        elif not should_be_offscreen and is_off:
     28            return False
     29    return not should_be_offscreen
     30 
     31 
     32 @pytest.mark.asyncio
     33 @pytest.mark.with_interventions
     34 async def test_enabled(client):
     35    assert await check_popup(client, False)
     36 
     37 
     38 @pytest.mark.asyncio
     39 @pytest.mark.without_interventions
     40 async def test_disabled(client):
     41    assert await check_popup(client, True)