0

I tried writing like this, however still the virtual browser opens.

from selenium import webdriver

option = webdriver.ChromeOptions()
option.headless = True
browser = webdriver.Chrome(options=option)
browser.get("https://www.youtube.com")

I have tried doing this with the Firefox browser as well, however with no success.

1 Answer 1

0

The code you gave as such will not work for firefox because the selenium driver is different and you will need to following statement

from selenium.webdriver.firefox.options import Options

For google chrome, try this

from selenium import webdriver

# Set Chrome options
c_opts = webdriver.ChromeOptions()
c_opts.add_argument('--headless')  
c_opts.add_argument('--disable-gpu')  #optional


#Now initialise the browser
browser = webdriver.Chrome(options=chrome_opts)

# Navigate to the URL
url = 'https://www.youtube.com'
browser.get()

Hope this works for you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.