[Webkit-unassigned] [Bug 279149] New: [WebDriver] imported/selenium/py/test/selenium/webdriver/common/alerts_tests.py::test_unexpected_alert_present_exception_contains_alert_text is failing due to wrong assertion

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 4 15:09:00 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=279149

            Bug ID: 279149
           Summary: [WebDriver]
                    imported/selenium/py/test/selenium/webdriver/common/al
                    erts_tests.py::test_unexpected_alert_present_exception
                    _contains_alert_text is failing due to wrong assertion
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebDriver
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: lmoura at igalia.com
                CC: bburg at apple.com

imported/selenium/py/test/selenium/webdriver/common/alerts_tests.py::test_unexpected_alert_present_exception_contains_alert_text

Failure:

driver = <selenium.webdriver.wpewebkit.webdriver.WebDriver (session="a336c4c1-4064-4f3c-a609-92f13071df7a")>, pages = <conftest.pages.<locals>.Pages object at 0x7acb0d4fc610>                                                                                                                                                

    @pytest.mark.xfail_firefox(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1279211")                                                                                                                                                                                                                                 
    @pytest.mark.xfail_remote(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1279211")                                                                                                                                                                                                                                  
    @pytest.mark.xfail_chrome                                                                                                                                                                                                                                                                                                 
    @pytest.mark.xfail_edge                                                                                                                                                                                                                                                                                                   
    def test_unexpected_alert_present_exception_contains_alert_text(driver, pages):                                                                                                                                                                                                                                           
        pages.load("alerts.html")                                                                                                                                                                                                                                                                                             
        driver.find_element(by=By.ID, value="alert").click()                                                                                                                                                                                                                                                                  
        alert = _wait_for_alert(driver)                                                                                                                                                                                                                                                                                       
        value = alert.text                                                                                                                                                                                                                                                                                                    
        with pytest.raises(UnexpectedAlertPresentException) as e:                                                                                                                                                                                                                                                             
            pages.load("simpleTest.html")                                                                                                                                                                                                                                                                                     
        assert value == e.value.alert_text                                                                                                                                                                                                                                                                                    
>       assert f"Alert Text: {value}" in str(e)                                                                                                                                                                                                                                                                               
E       AssertionError: assert 'Alert Text: cheese' in '<ExceptionInfo UnexpectedAlertPresentException() tblen=5>'                                                                                                                                                                                                            
E        +  where '<ExceptionInfo UnexpectedAlertPresentException() tblen=5>' = str(<ExceptionInfo UnexpectedAlertPresentException() tblen=5>) 

The failure happens because `pytest.raises` wraps `UnexpectedAlertPresentException` in a `ExceptionInfo` object. As such, the assertion should compare to `str(e.value)` instead to `str(e)`.

This should be fixed upstream and imported back to WebKit.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240904/3fd4a889/attachment-0001.htm>


More information about the webkit-unassigned mailing list