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
3 Answers 3
Try this:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
optionss = Options()
optionss.add_argument("--start-maximized")
optionss.add_argument("--disable-popup-blocking")
optionss.add_argument("--ignore-certificate-errors")
driver = webdriver.Chrome(options=optionss)
If you already doing this, please show us all code.
[EDIT]
After you updated the post, i need to ask:
optionss.add_argument()
Is that work?
I'm asking 'cause your "optionss" variable is not an instance of "Options()" and i think is it that cause the crash on webdriver.
1 Comment
driver = webdriver.Chrome(). Otherwise, it will crash, or it will open EdgeYou are trying to launch Chrome using Edge options, so it is going to launch Edge instead. Don't do that.
from selenium.webdriver.edge.options import Options
Comments
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
Comments
Explore related questions
See similar questions with these tags.
Options()andChrome(). Adding arguments to an options instance and using that to launch Chrome works fine. If it doesn't for you, please include the full error message.