test_1971504_wallapop_com.py (1656B)
1 import asyncio 2 3 import pytest 4 from webdriver.error import StaleElementReferenceException 5 6 URL = "https://es.wallapop.com/search" 7 MOBILE_FILTERS_CSS = "walla-button[data-testid=single-access-filters].hydrated" 8 LEFT_SLIDER_CSS = "#fromSelector" 9 10 11 async def does_left_slider_work(client): 12 await client.navigate(URL) 13 client.hide_elements("#onetrust-consent-sdk") 14 client.await_css(MOBILE_FILTERS_CSS, is_displayed=True).click() 15 for i in range(5): 16 try: 17 client.await_css( 18 "button", 19 condition="elem.innerText.includes('Precio')", 20 is_displayed=True, 21 ).click() 22 break 23 except StaleElementReferenceException: 24 await client.stall(0.5) 25 slider = client.await_css(LEFT_SLIDER_CSS, is_displayed=True) 26 await asyncio.sleep(0.5) 27 28 # Unfortunately, on desktop range thumbs do not react to any attempts to 29 # drag them with WebDriver. However they do on Android, which is enough 30 # for us to be able to test them. 31 32 def slider_value(): 33 return client.execute_script("return arguments[0].value", slider) 34 35 orig_value = slider_value() 36 37 coords = client.get_element_screen_position(slider) 38 coords = [coords[0] + 10, coords[1] + 10] 39 await client.apz_down(coords=coords) 40 for i in range(25): 41 await asyncio.sleep(0.01) 42 coords[0] += 5 43 await client.apz_move(coords=coords) 44 return orig_value != slider_value() 45 46 47 @pytest.mark.only_platforms("android") 48 @pytest.mark.asyncio 49 @pytest.mark.without_interventions 50 async def test_regression(client): 51 assert await does_left_slider_work(client)