test_1978572_store_renishaw_com.py (1653B)
1 import asyncio 2 3 import pytest 4 5 URL = "https://store.renishaw.com/en-GB/category/styli-renishaw-straight?Thread=%3AM2&TipMaterial=%3ARuby" 6 POPUPS_CSS = "#onetrust-consent-sdk, [data-testid=toast]" 7 MOBILE_FILTERS_CSS = "[data-testid=plp-filters-open-modal-button]" 8 LEFT_SLIDER_CSS = "details.bg-primary #undefined-min" 9 10 11 async def does_left_slider_work(client): 12 await client.navigate(URL) 13 client.hide_elements(POPUPS_CSS) 14 client.await_css(MOBILE_FILTERS_CSS, is_displayed=True).click() 15 slider = client.await_css(LEFT_SLIDER_CSS, is_displayed=True) 16 await asyncio.sleep(0.5) 17 18 # Unfortunately, on desktop range thumbs do not react to any attempts to 19 # drag them with WebDriver. However they do on Android, which is enough 20 # for us to be able to test them. 21 22 def slider_value(): 23 return client.execute_script("return arguments[0].value", slider) 24 25 orig_value = slider_value() 26 27 coords = client.get_element_screen_position(slider) 28 coords = [coords[0] + 4, coords[1] + 4] 29 await client.apz_down(coords=coords) 30 for i in range(25): 31 await asyncio.sleep(0.01) 32 coords[0] += 5 33 await client.apz_move(coords=coords) 34 return orig_value != slider_value() 35 36 37 @pytest.mark.only_platforms("android") 38 @pytest.mark.actual_platform_required 39 @pytest.mark.asyncio 40 @pytest.mark.with_interventions 41 async def test_enabled(client): 42 assert await does_left_slider_work(client) 43 44 45 @pytest.mark.only_platforms("android") 46 @pytest.mark.actual_platform_required 47 @pytest.mark.asyncio 48 @pytest.mark.without_interventions 49 async def test_disabled(client): 50 assert not await does_left_slider_work(client)