0

This is my code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import sys
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import os

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')

browser = webdriver.Chrome('/Users/opulentbase/Downloads/chromedriver')

browser.get('https://www.gooogle.com/')

searchBar = browser.find_element_by_name('q')

userSearch = input("Please enter a search: ")

I tried to run this code but it keeps opening the browser instead of running headless. How do I write the code so that the program runs headless without opening a window?

Thanks in advance, i'm new to coding!

1
  • It looks like you’re not using the options when creating the driver, no? As an aside, you seem to be mixing multiple naming conventions. Commented May 11, 2020 at 19:16

1 Answer 1

1

Make sure you add the options argument to your browser like so:

browser = webdriver.Chrome('/Users/opulentbase/Downloads/chromedriver', options=chrome_options)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.