Python 3.x 当作为sudo运行时,Selenium脚本不会在Firefox中运行
我有以下简单的脚本Python 3.x 当作为sudo运行时,Selenium脚本不会在Firefox中运行,python-3.x,selenium,selenium-webdriver,geckodriver,Python 3.x,Selenium,Selenium Webdriver,Geckodriver,我有以下简单的脚本 from selenium import webdriver from selenium.webdriver.common.keys import Keys # Create a new instance of the Firefox driver browser = webdriver.Firefox() browser.get('https://www.google.com') browser.quit() 当我以普通用户的身份运行这个脚本时,python3te
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Create a new instance of the Firefox driver
browser = webdriver.Firefox()
browser.get('https://www.google.com')
browser.quit()
当我以普通用户的身份运行这个脚本时,python3test.py
,它会正确执行。但当我以root用户sudo python3 test.py
的身份运行此脚本时,它将退出并出现以下错误:
selenium.common.exceptions.WebDriverException:消息:无效参数:无法终止已退出的进程
有一个需求需要脚本作为根用户执行。我应该怎么做才能合并它?试着在无头模式下运行它
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
browser = webdriver.Firefox(options=options)
browser.get('https://www.google.com')
browser.quit()
嗨,Karthik,我不想在无头模式下运行。我特别想看看GUI。