selenium-webdriverautomationbrowser-automation

Python Selenium is not able to open Chrome driver when having options in parameters


i wanted to start experimenting with selenium with python to automate a few stuff. But i can only open Edge when i place in the options parameter (which i believe still does not work properly). I can open chrome, but only if its driver = webdriver.Chrome(). Any other parameters will either crash, like webdriver.Chrome(executable_path=r"...") or open Edge, like webdriver.Chrome(options=optionss)

The options that i have so far are:

optionss.add_argument("--start-maximized")
optionss.add_argument("--disable-popup-blocking")
optionss.add_argument("--ignore-certificate-errors")

and some more stuff for prefs

Here is the code i have now:

from selenium import webdriver
from selenium.webdriver.edge.options import Options


url = "https://example.site.com"

optionss.add_argument("--start-maximized")
#optionss.add_argument("--disable-popup-blocking")
#optionss.add_argument("--ignore-certificate-errors")

prefs = {
        "download.default_directory": r"C:\example\dir",
        "download.prompt_for_download":False,
        "safebrowsing.enabled":False
        }

optionss.add_experimental_option("prefs", prefs)

driver = webdriver.Chrome(options=optionss)
driver.get(url)

As stated, chrome will open only if there is no options=optionss parameter. Otherwise it will crash or open Edge

This is the error that i get when I have options=optionss in webdriver.Chrome(): SessionNotCreatedException: Message: session not created: No matc hing capabilities found


Solution

  • Thank you everyone for your help. Sorry for late response. The simple solution that i found was instead of doing optionss = Options(), do optionss = ChromeOptions()

    So simple but yet so weird