Closed Bug 1972726 Opened 1 year ago Closed 1 year ago

Stabilize tests/address_bar_and_search/test_search_suggestions.py

Categories

(Mozilla QA :: STArFox, defect)

Version 4
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1972839

People

(Reporter: benchatt, Unassigned)

References

Details

Started 140.0b9

________________________ test_search_suggests_enabled _________________________
[gw1] win32 -- Python 3.11.9 C:\Users\runneradmin\.virtualenvs\fx-desktop-qa-automation-TuKDxZW9\Scripts\python.exe

driver = <selenium.webdriver.firefox.webdriver.WebDriver (session="d0a8a079-4036-437e-8426-473cd54c72da")>

    def test_search_suggests_enabled(driver: Firefox):
        """
        C1618400: Firefox Suggest displays sponsored and non-sponsored suggestions when enabled in Preferences
        """
        nav = Navigation(driver)
        prefs = AboutPrefs(driver, category="search")
        actions = BrowserActions(driver)
    
        prefs.open()
    
        # Enable "Show search suggestions" if disabled
        suggestions_checkbox = prefs.get_element("show-suggestions")
        if not suggestions_checkbox.is_selected():
            suggestions_checkbox.click()
    
        nonsponsored_checkbox = prefs.get_element("firefox-suggest-nonsponsored")
        assert nonsponsored_checkbox.is_selected(), (
            "'firefox-suggest-nonsponsored' checkbox not checked"
        )
    
        sponsored_checkbox = prefs.get_element("firefox-suggest-sponsored")
        assert sponsored_checkbox.is_selected(), (
            "'firefox-suggest-sponsored' checkbox not checked"
        )
    
        # Check for sponsored suggestion
        # Trigger the suggests once. First time, it's not populated correctly in automation
        with driver.context(driver.CONTEXT_CHROME):
            actions.search(SEARCH_TERM_SPONSORED, with_enter=False)
            sleep(SECONDS)
    
        # Then load up suggests again and check for sponsored suggestion
        found_sponsored = False
        retries = 0
        while not found_sponsored and retries < RETRY_LIMIT:
            actions.search(SEARCH_TERM_SPONSORED, with_enter=False)
            sleep(SECONDS)  # Give Firefox time to populate suggests list
            with driver.context(driver.CONTEXT_CHROME):
                found_sponsored = any(
                    item.get_attribute("aria-label") == "Sponsored"
                    for item in nav.get_elements("sponsored-suggestion")
                )
            retries += 1
        assert found_sponsored, (
            f"No sponsored suggestion found after {RETRY_LIMIT} retries."
        )
    
        # Check for non-sponsored suggestion
        actions.search(SEARCH_TERM_NON_SPONSORED, with_enter=False)
        sleep(SECONDS)  # Give Firefox time to populate suggests list
        with driver.context(driver.CONTEXT_CHROME):
            nav.get_element("firefox-suggest")
            titles = nav.get_elements("suggestion-titles")
            found_non_sponsored = any(
                "Wikipedia - wiki.phtml" in title.text for title in titles
            )
>       assert found_non_sponsored, "Non-sponsored suggestion not found"
E       AssertionError: Non-sponsored suggestion not found
E       assert False

tests\address_bar_and_search\test_search_suggestions.py:78: AssertionError
Status: NEW → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1972839
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.