test_1864999_autotrader_ca.py (1775B)
1 import time 2 3 import pytest 4 from webdriver import NoSuchElementException, WebDriverException 5 6 URL = "https://www.autotrader.ca/lst?adtype=Dealer&atype=C&cy=CA&damaged_listing=exclude&desc=0&hprc=True&inMarket=advancedSearch&lat=49.1848258972168&loc=v2p5p4&lon=-121.93928527832031&offer=U&prv=British%20Columbia&prx=250&rcp=20&rcs=0&search_id=hf3of1x3pk&showcpo=1&size=20&sort=price&srt=4&sts=New&wcp=False&zip=V2P5P4%20Chilliwack%2C%20BC&zipr=250" 7 8 COOKIES_CSS = "#cookie-banner" 9 FILTER_BUTTON_CSS = "button[class^=SearchMaskFilterTags_mobile_filter]" 10 MAKE_FILTER_CSS = "[aria-controls=make-model-filter-details]" 11 MAKE_FILTER_OPTS_CSS = "#select-make-container" 12 13 14 async def are_filter_options_onscreen(client): 15 await client.navigate(URL) 16 17 try: 18 client.remove_element(client.await_css(COOKIES_CSS, timeout=4)) 19 except NoSuchElementException: 20 pass 21 22 # try clicking the button a few times until it hides itself 23 btn = client.await_css(FILTER_BUTTON_CSS, is_displayed=True) 24 for i in range(5): 25 try: 26 btn.click() 27 time.sleep(1) 28 except WebDriverException: 29 break 30 31 # scroll to one of the filters and "open" it 32 flt = client.await_css(MAKE_FILTER_CSS, is_displayed=True) 33 client.scroll_into_view(flt) 34 flt.click() 35 36 # check whether the container of the filter is off-screen 37 opts = client.await_css(MAKE_FILTER_OPTS_CSS, is_displayed=True) 38 return client.execute_script( 39 """ 40 return arguments[0].getBoundingClientRect().right > window.innerWidth; 41 """, 42 opts, 43 ) 44 45 46 @pytest.mark.only_platforms("android") 47 @pytest.mark.asyncio 48 @pytest.mark.without_interventions 49 async def test_regression(client): 50 assert not await are_filter_options_onscreen(client)