how can i remove notifications and alerts from browser? selenium python 2.7.7

前端 未结 6 2049
闹比i
闹比i 2020-12-01 15:43

I am trying to submit information in a webpage, but selenium throws this error:

UnexpectedAlertPresentException: Alert Text: This page is asking you

6条回答
  •  独厮守ぢ
    2020-12-01 16:13

    With the latest version of Firefox the above preferences didn't work.

    Below is the solution which disable notifications using Firefox object

    _browser_profile = webdriver.FirefoxProfile()
    _browser_profile.set_preference("dom.webnotifications.enabled", False)
    webdriver.Firefox(firefox_profile=_browser_profile)
    

    Disable notifications when using Remote Object: webdriver.Remote(desired_capabilities=_desired_caps, command_executor=_url, options=_custom_options, browser_profile=_browser_profile)

    selenium==3.11.0

提交回复
热议问题