test_1886566_qceservices_quezoncity_gov_ph.py (2405B)
1 import pytest 2 from webdriver.error import NoSuchElementException 3 4 URL = "https://qceservices.quezoncity.gov.ph/qcvaxeasy" 5 6 IFRAME_CSS = "iframe#qcid_iframe" 7 RECAPTCHA_CSS = "iframe[title*=captcha]" 8 9 10 async def is_iframe_visible(client, in_headless_mode): 11 await client.navigate(URL) 12 13 try: 14 client.await_css(RECAPTCHA_CSS, is_displayed=True, timeout=5) 15 if in_headless_mode: 16 pytest.xfail("Skipping as cannot do reCAPTCHA in headless mode.") 17 return False 18 try: 19 print("\a") 20 iframe = client.await_css(IFRAME_CSS, is_displayed=True, timeout=120) 21 except NoSuchElementException: 22 pytest.xfail( 23 "Timed out waiting for reCAPTCHA to be completed. Please try again." 24 ) 25 return False 26 except NoSuchElementException: 27 iframe = client.await_css(IFRAME_CSS, is_displayed=True) 28 pass 29 30 assert iframe 31 return client.execute_script( 32 """ 33 return arguments[0].getBoundingClientRect().height > 200; 34 """, 35 iframe, 36 ) 37 38 39 @pytest.mark.only_firefox_versions(min=146) 40 @pytest.mark.enable_webkit_fill_available 41 @pytest.mark.asyncio 42 @pytest.mark.without_interventions 43 async def test_now_works_with_just_pref(client, in_headless_mode): 44 assert await is_iframe_visible(client, in_headless_mode) 45 46 47 @pytest.mark.only_firefox_versions(min=146) 48 @pytest.mark.disable_webkit_fill_available 49 @pytest.mark.asyncio 50 @pytest.mark.with_interventions 51 async def test_still_works_without_pref(client, in_headless_mode): 52 assert await is_iframe_visible(client, in_headless_mode) 53 54 55 @pytest.mark.only_firefox_versions(min=146) 56 @pytest.mark.disable_webkit_fill_available 57 @pytest.mark.asyncio 58 @pytest.mark.without_interventions 59 async def test_still_does_not_work_without_pref_or_intervention( 60 client, in_headless_mode 61 ): 62 assert not await is_iframe_visible(client, in_headless_mode) 63 64 65 @pytest.mark.only_firefox_versions(max=145) 66 @pytest.mark.asyncio 67 @pytest.mark.without_interventions 68 async def test_did_work_with_intervention(client, in_headless_mode): 69 assert await is_iframe_visible(client, in_headless_mode) 70 71 72 @pytest.mark.only_firefox_versions(max=145) 73 @pytest.mark.asyncio 74 @pytest.mark.without_interventions 75 async def test_did_not_work_without_intervention(client, in_headless_mode): 76 assert not await is_iframe_visible(client, in_headless_mode)