1

I am having some issues when i am running my code, on some sites i get a popup / alert like in this image:

https://imgur.com/a/e6kxmYx

Only on some pages and sites, the code i'm using to initiate the driver is:

# init driver ...
def init_driver(using_linux, proxy):
    options = Options()
    options.headless = False
    options.add_argument('start-maximized')
    #options.add_argument('--disable-infobars')
    options.add_argument('--disable-notifications')
    options.add_argument('--disable-extensions')
    options.add_argument('--log-level=3') 
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--ignore-ssl-errors')
    options.add_experimental_option("excludeSwitches" , ["enable-automation","load-extension"])
    prefs = {'profile.default_content_setting_values.notifications' : 2}
    options.add_experimental_option('prefs', prefs)
    if proxy == "0.0.0.0:0":
        print("--> PROXY DISABLED ...")
    else:
        print("--> USING PROXY: " + str(proxy) + " ...")
        options.add_argument('--proxy-server=%s' % proxy)
    if using_linux:
        return webdriver.Chrome("/usr/bin/chromedriver", chrome_options=options)
    else:
        return webdriver.Chrome("chromedriver.exe", chrome_options=options)

Is there as way I can disable all popups and alerts when using Selenium or do they all have to be individually dealt with? i know i can switch off the notifications it would be good to shut off everything that could hinder a task being done.

any help would be appreciated.

AndiCover
  • 1,724
  • 3
  • 17
  • 38
tess
  • 29
  • 5

0 Answers0