I'm new to python and I tried to disable the Chrome extensions using selenium in python.
By using the following lines
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-extensions')
chrome = webdriver.Chrome(chrome_options=chrome_options)
But first I tried to import the chromeOptions with the following import statement
from selenium.webdriver.chrome.options import Options
I also tried this , but with no result.
from selenium.webdriver.chrome import options
So I looked up on the internet and everyone used the import statements like this?
And it keeps throwing error and says that the following import is not used?
When I try to used the ChromeOption() it doesn't work but it immediately gave me errors and said that it isn't imported. Meanwhile I have the chrome option line in my code.
Any help would be appreciated
Thank you
CodePudding user response:
I think the problem with the code is the line:
chrome_options = webdriver.ChromeOptions()
To fix this you can simply start by importing Options()
for the imports you can either do it like this:
from selenium.webdriver.chrome.options import Options
and then call
chrome_options = Options()
or if you import :
from selenium.webdriver.chrome import options
then you need to call
chrome_options = options.Options()
once you initiated chrome_options, then you can write the rest of your code:
chrome_options.add_argument("--disable-extensions")
browser = webdriver.Chrome(chrome_options=chrome_options)
I hope this helped, if you still encounter errors do not hesitate to share the error messages here.