【发布时间】:2020-08-27 10:56:00
【问题描述】:
这是我的代码:
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: ")
我尝试运行此代码,但它一直打开浏览器而不是无头运行。如何编写代码让程序在不打开窗口的情况下无头运行?
提前致谢,我是编码新手!
【问题讨论】:
-
看起来您在创建驱动程序时没有使用这些选项,不是吗?顺便说一句,您似乎混合了多种命名约定。