tor-browser

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

test_1946409_lush_com.py (1206B)


      1 import pytest
      2 
      3 URL = "https://www.lush.com/uk/en/p/spa-party-voucher"
      4 
      5 COOKIES_CSS = "#portal-cookie-banner__content"
      6 BOTTOM_COOKIE_BUTTON_CSS = "button[data-test=cookie__accept]"
      7 
      8 
      9 async def is_cookie_banner_onscreen(client):
     10    await client.navigate(URL, wait="none")
     11    cookies = client.await_css(COOKIES_CSS, is_displayed=True)
     12    button = client.await_css(BOTTOM_COOKIE_BUTTON_CSS, is_displayed=True)
     13    return client.execute_async_script(
     14        """
     15        const [cookies, button, done] = arguments;
     16        setInterval(() => {
     17          // wait for the animation to complete of the cookie bar sliding up.
     18          if (cookies.style.transform === "translate3d(0px, 0%, 0px)") {
     19            done(button.getBoundingClientRect().bottom <= screen.height);
     20          }
     21        }, 100);
     22      """,
     23        cookies,
     24        button,
     25    )
     26 
     27 
     28 @pytest.mark.only_platforms("android")
     29 @pytest.mark.asyncio
     30 @pytest.mark.with_interventions
     31 async def test_enabled(client):
     32    assert await is_cookie_banner_onscreen(client)
     33 
     34 
     35 @pytest.mark.only_platforms("android")
     36 @pytest.mark.asyncio
     37 @pytest.mark.without_interventions
     38 async def test_disabled(client):
     39    assert not await is_cookie_banner_onscreen(client)