【发布时间】:2020-07-17 01:31:51
【问题描述】:
我知道它在 linux(python+selenium) 上的无头模式下也可以正常工作,用于无头模式
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
chrome_options=chrome_options)
我的要求:想要运行 selenium/python 脚本而不需要无头 chrome 模式(即非无头) 但是当我评论或删除行(--headless)时,
chrome_options = webdriver.ChromeOptions()
#chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
chrome_options=chrome_options)
甚至(--no-headless)
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
chrome_options=chrome_options)
在运行 python 脚本时,上面的(非无头)更改给了我错误,
Looking for [chromedriver 84.0.4147.30 linux64] driver in cache
File found in cache by path [/***/drivers/chromedriver/84.0.4147.30/linux64/chromedriver]
Error in UI Test: local variable 'browser' referenced before assignment
如果可能的话,有人可以帮我实现这个要求吗?
【问题讨论】:
标签: python-3.x linux selenium selenium-chromedriver