How would this work? I got no idea I'm kinda new to selenium lol.
Asked
Active
Viewed 3,994 times
1 Answers
2
If you are using chrome driver you can do that by adding headless to the browser options like so:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
with webdriver.Chrome(options=options) as browser:
browser.get(url)
# # Do other stuff
or
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
browser = webdriver.Chrome(options=options)
browser.get(url)
# # do things
browser.close()

Ahmed Abuthwabah
- 259
- 1
- 8
-
-
@2x0Z I have the exact same code and it's working, you must be doing something wrong, make sure that you are passing the options keyword to chrome driver, I have included that in the answer check it and let me know if it's worked – Ahmed Abuthwabah Sep 19 '20 at 18:38
-
-
what do you mean by not exist? `with` works like a resource manager in this case it will close the browser automatically when the code inside it is executed, you don't have to use `with` but it's recommended to use it. you can use it like this: browser = webdriver.Chrome(options=options) browser.get(url) # # do things browser.close() – Ahmed Abuthwabah Sep 19 '20 at 18:51
-
-
Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home – 2x0z Sep 20 '20 at 10:21