tor-browser

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

test_1968198_metacritic_com.py (1408B)


      1 import asyncio
      2 
      3 import pytest
      4 
      5 URL = "https://www.metacritic.com/browse/game/"
      6 MOBILE_FILTERS_CSS = "[data-testid=button-filters] button"
      7 LEFT_SLIDER_CSS = "input[name=releaseYearMin]"
      8 
      9 
     10 async def does_left_slider_work(client):
     11    await client.navigate(URL)
     12    client.await_css(MOBILE_FILTERS_CSS, is_displayed=True).click()
     13    slider = client.await_css(LEFT_SLIDER_CSS, is_displayed=True)
     14    await asyncio.sleep(0.5)
     15 
     16    # Unfortunately, on desktop range thumbs do not react to any attempts to
     17    # drag them with WebDriver. However they do on Android, which is enough
     18    # for us to be able to test them.
     19 
     20    def slider_value():
     21        return client.execute_script("return arguments[0].value", slider)
     22 
     23    orig_value = slider_value()
     24 
     25    coords = client.get_element_screen_position(slider)
     26    coords = [coords[0] + 4, coords[1] + 4]
     27    await client.apz_down(coords=coords)
     28    for i in range(25):
     29        await asyncio.sleep(0.01)
     30        coords[0] += 5
     31        await client.apz_move(coords=coords)
     32    return orig_value != slider_value()
     33 
     34 
     35 @pytest.mark.only_platforms("android")
     36 @pytest.mark.asyncio
     37 @pytest.mark.with_interventions
     38 async def test_enabled(client):
     39    assert await does_left_slider_work(client)
     40 
     41 
     42 @pytest.mark.only_platforms("android")
     43 @pytest.mark.asyncio
     44 @pytest.mark.without_interventions
     45 async def test_disabled(client):
     46    assert not await does_left_slider_work(client)