commit c14352afe04ae145b13cf0d752beaed5db22f6a2 parent fa9c5cdb882ab842125b67c0238b94b24387d0c9 Author: Thomas Wisniewski <twisniewski@mozilla.com> Date: Fri, 31 Oct 2025 15:54:28 +0000 Bug 1994456 - fix webcompat interventions automated tests; r=ksenia Differential Revision: https://phabricator.services.mozilla.com/D270752 Diffstat:
13 files changed, 43 insertions(+), 87 deletions(-)
diff --git a/testing/webcompat/client.py b/testing/webcompat/client.py @@ -1584,8 +1584,9 @@ class Client: const e = arguments[0], s = window.getComputedStyle(e), v = s.visibility === "visible", - o = Math.abs(parseFloat(s.opacity)); - return e.getClientRects().length > 0 && v && (isNaN(o) || o === 1.0); + o = Math.abs(parseFloat(s.opacity)), + d = s.display === "contents" || e.getClientRects().length > 0; + return d && v && (isNaN(o) || o === 1.0); """, args=[element], ) diff --git a/testing/webcompat/interventions/tests/test_1724868_news_yahoo_co_jp.py b/testing/webcompat/interventions/tests/test_1724868_news_yahoo_co_jp.py @@ -27,7 +27,7 @@ async def go(client, should_work): is_displayed=True, ) if _iframe: - client.switch_frame(_iframe) + client.switch_to_frame(_iframe) continue if should_work: assert _supported or _vpn1 or _vpn2 diff --git a/testing/webcompat/interventions/tests/test_1830739_1902446_casinobrango_com.py b/testing/webcompat/interventions/tests/test_1830739_1902446_casinobrango_com.py @@ -8,7 +8,7 @@ SUPPORTED_CSS = "#game_main" async def get_to_page(client): await client.navigate(URL) - client.switch_to_frame(client.await_css(IFRAME_CSS)) + client.switch_to_frame(client.await_css(IFRAME_CSS, timeout=45)) @pytest.mark.only_platforms("android") diff --git a/testing/webcompat/interventions/tests/test_1830739_1947963_slotmadness_com.py b/testing/webcompat/interventions/tests/test_1830739_1947963_slotmadness_com.py @@ -10,7 +10,7 @@ SUPPORTED_CSS = "#game_main" async def get_to_page(client): await client.navigate(URL) client.soft_click(client.await_css(PRACTICE_FIRST_GAME_CSS)) - client.switch_frame(client.await_css(GAME_IFRAME_CSS)) + client.switch_to_frame(client.await_css(GAME_IFRAME_CSS)) @pytest.mark.only_platforms("android") diff --git a/testing/webcompat/interventions/tests/test_1830739_1964350_bonusblitz_com.py b/testing/webcompat/interventions/tests/test_1830739_1964350_bonusblitz_com.py @@ -9,7 +9,7 @@ SUPPORTED_CSS = "#game_main" async def get_to_page(client): await client.navigate(URL) - client.switch_frame(client.await_css(GAME_IFRAME_CSS)) + client.switch_to_frame(client.await_css(GAME_IFRAME_CSS)) @pytest.mark.only_platforms("android") diff --git a/testing/webcompat/interventions/tests/test_1897724_app_homewyse_com.py b/testing/webcompat/interventions/tests/test_1897724_app_homewyse_com.py @@ -1,21 +0,0 @@ -import pytest - -URL = "https://app.homewyse.com/accounts/register/" -SUPPORTED_CSS = "#newacct-form" -UNSUPPORTED_TEXT = "Firefox is not supported" - - -@pytest.mark.asyncio -@pytest.mark.with_interventions -async def test_enabled(client): - await client.navigate(URL) - assert client.await_css(SUPPORTED_CSS) - assert not client.find_text(UNSUPPORTED_TEXT) - - -@pytest.mark.asyncio -@pytest.mark.without_interventions -async def test_disabled(client): - await client.navigate(URL) - assert client.await_text(UNSUPPORTED_TEXT) - assert not client.find_css(SUPPORTED_CSS) diff --git a/testing/webcompat/interventions/tests/test_1902407_www_sigadoc_mt_gov_br.py b/testing/webcompat/interventions/tests/test_1902407_www_sigadoc_mt_gov_br.py @@ -23,6 +23,6 @@ async def test_enabled(client): @pytest.mark.without_interventions async def test_disabled(client): await client.navigate(URL, wait="none") - client.await_css(HERO_CSS, is_displayed=True) + client.await_css(HERO_CSS, is_displayed=True, timeout=30) assert client.await_css(UNSUPPORTED_CSS, is_displayed=True) assert client.await_text(UNSUPPORTED_TEXT, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1902464_workhub_transcribeme_com.py b/testing/webcompat/interventions/tests/test_1902464_workhub_transcribeme_com.py @@ -1,9 +1,8 @@ -import asyncio - import pytest URL = "https://workhub.transcribeme.com/Exam" +CAPTCHA_CSS = "re-captcha" USERNAME_CSS = "input[name=username]" PASSWORD_CSS = "input[name=password]" EXPIRED_CSS = "app-renewpassword" @@ -25,17 +24,24 @@ async def does_unsupported_popup_appear(client, credentials): password.send_keys(credentials["password"]) sign_in.click() - unsupported, expired = client.await_first_element_of( - [ - client.css(UNSUPPORTED_CSS), - client.css(EXPIRED_CSS), - ] - ) + for _ in range(10): + captcha, unsupported, expired = client.await_first_element_of( + [ + client.css(CAPTCHA_CSS), + client.css(UNSUPPORTED_CSS), + client.css(EXPIRED_CSS), + ] + ) + if captcha: + print("\a") # beep to let the user know to do the captcha + client.await_element_hidden(client.css(CAPTCHA_CSS), timeout=90) + else: + break if expired: pytest.skip("Your password has expired. Please visit the site and renew it.") return - await asyncio.sleep(1) + await client.stall(1) return client.find_css(UNSUPPORTED_CSS, is_displayed=True) diff --git a/testing/webcompat/interventions/tests/test_1911253_qq_com.py b/testing/webcompat/interventions/tests/test_1911253_qq_com.py @@ -16,7 +16,7 @@ async def does_checkmark_appear(client): client.await_css(LOGIN_CSS, is_displayed=True).click() client.await_css(CHECKBOX_CSS, is_displayed=True).click() client.await_css(QQ_BUTTON_CSS, is_displayed=True).click() - client.switch_frame(client.await_css(IFRAME_CSS)) + client.switch_to_frame(client.await_css(IFRAME_CSS)) # by the time this console message is logged, the checkbox should be ready to check await (await client.promise_console_message_listener(WAIT_LOG_MSG)) return not client.is_one_solid_color(client.await_css(REPLACED_CSS)) diff --git a/testing/webcompat/interventions/tests/test_1914327_media_qdnd_vn.py b/testing/webcompat/interventions/tests/test_1914327_media_qdnd_vn.py @@ -1,4 +1,5 @@ import pytest +from webdriver.bidi.error import UnknownErrorException URL = "https://media.qdnd.vn/phim-truyen-thong-tai-lieu/nhung-hinh-anh-dau-tien-trong-du-an-phim-ve-bo-doi-cu-ho-nam-2024-59811" PLAY_BUTTON_CSS = "#hpcplayer .media-icon-play" @@ -20,7 +21,10 @@ async def calls_canPlayType(client, type): Object.defineProperty(proto, "canPlayType", def); """ ) - await client.navigate(URL) + try: + await client.navigate(URL, no_skip=True) + except UnknownErrorException: + pass play, err = client.await_first_element_of( [ client.css(PLAY_BUTTON_CSS), @@ -28,8 +32,10 @@ async def calls_canPlayType(client, type): ], is_displayed=True, ) + await client.stall(2) if play: play.click() + await client.stall(2) return client.execute_script( """ return window.__cpts.includes(arguments[0]); diff --git a/testing/webcompat/interventions/tests/test_1923656_ipmph_com.py b/testing/webcompat/interventions/tests/test_1923656_ipmph_com.py @@ -14,7 +14,7 @@ VPN_MESSAGE = "Possibly region-locked. Please try again using a VPN set to Hong async def test_enabled(client): await client.navigate(URL, wait="none") try: - client.switch_frame(client.await_css(IFRAME_CSS, timeout=30)) + client.switch_to_frame(client.await_css(IFRAME_CSS, timeout=30)) except Exception: pytest.skip(VPN_MESSAGE) return diff --git a/testing/webcompat/interventions/tests/test_1939248_rosasthai_com.py b/testing/webcompat/interventions/tests/test_1939248_rosasthai_com.py @@ -1,25 +1,28 @@ import pytest -from webdriver.error import NoSuchElementException +from webdriver.error import NoSuchElementException, StaleElementReferenceException URL = "https://rosasthai.com/locations" COOKIES_CSS = "#ccc" VIEW_ALL_CSS = "#view-all" -LOADING_CSS = ".loading-location" -SUCCESSFUL_LOAD_CSS = "#panel > [id]" +FIRST_CARD_CSS = "#location-results [id^=card-]" async def does_clicking_work(client): await client.navigate(URL, wait="none") client.hide_elements(COOKIES_CSS) - client.await_css(VIEW_ALL_CSS, is_displayed=True).click() + # on failure, the location cards don't load. we also confirm that the + # cards change after clicking "view all", just in case. try: - client.await_css(LOADING_CSS, is_displayed=True, timeout=3) + first_card = client.await_css(FIRST_CARD_CSS, is_displayed=True) except NoSuchElementException: return False - client.await_element_hidden(client.css(LOADING_CSS)) - client.await_css(SUCCESSFUL_LOAD_CSS, is_displayed=True) - return True + client.await_css(VIEW_ALL_CSS, is_displayed=True).click() + try: + first_card.click() + return False + except StaleElementReferenceException: + return True @pytest.mark.asyncio diff --git a/testing/webcompat/interventions/tests/test_1993201_portal_pilot_ly.py b/testing/webcompat/interventions/tests/test_1993201_portal_pilot_ly.py @@ -1,39 +0,0 @@ -import pytest - -URL = "https://previewinsights.qualtrics.com/jfe/form/SV_a5Gnoq0OsdUzvGm?Q_DL=hq7SUdQWjweSxhT_a5Gnoq0OsdUzvGm_CGC_DNCiEfKhsuDlymq&Q_CHL=email" - -WATCH_NOW_CSS = "a[href*='portal.pilot.ly/process-target']" -AVANTI_CSS = "button.begin-registration" -SUPPORTED_CSS = "#root .pilotly-player" -UNSUPPORTED_TEXT1 = "Firefox not supported" -UNSUPPORTED_TEXT2 = "Google Chrome" - - -async def get_to_page(client): - await client.navigate(URL, wait="none") - client.soft_click(client.await_css(WATCH_NOW_CSS, is_displayed=True)) - client.soft_click(client.await_css(AVANTI_CSS, is_displayed=True)) - - -@pytest.mark.asyncio -@pytest.mark.with_interventions -async def test_enabled(client): - await get_to_page(client) - assert client.await_css(SUPPORTED_CSS, is_displayed=True) - assert not client.find_text(UNSUPPORTED_TEXT2, is_displayed=True) - assert not client.find_text(UNSUPPORTED_TEXT2, is_displayed=True) - - -@pytest.mark.asyncio -@pytest.mark.without_interventions -async def test_disabled(client): - await get_to_page(client) - no_firefox, use_chrome = client.await_first_element_of( - [ - client.text(UNSUPPORTED_TEXT1), - client.text(UNSUPPORTED_TEXT2), - ], - is_displayed=True, - ) - assert no_firefox or use_chrome - assert not client.find_css(SUPPORTED_CSS, is_displayed=True)