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

前端 未结 6 2058
闹比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 15:53

    For Google Chrome and v3 of Selenium you may receive "DeprecationWarning: use options instead of chrome_options", so you will want to do the following:

    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    
    options = webdriver.ChromeOptions()
    options.add_argument('--disable-notifications')
    driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
    

    Note: I am using webdriver-manager, but this also works with specifying the executable_path.

提交回复
热议问题