【发布时间】:2021-04-01 07:06:23
【问题描述】:
我的代码在某些 PC 上运行正常,但有一个代码不会打开新的私人会话,在这种特殊情况下,它会在已打开的同一窗口中加载当前的 chrome 配置文件。 我尝试查看一些 stackoverflow 问题,看看是否发生在其他人身上,但没有成功。尝试查看此命令行列表“https://peter.sh/experiments/chromium-command-line-switches/”以查看是否有帮助,但我不知道如何使其工作。 即使没有打开会话,它也会加载默认用户配置文件并且没有任何反应。 Selenium、chrome 和 chromedriver 是最新的并具有匹配的版本。
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.common.exceptions import NoSuchElementException as NSEE
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--start-maximized')
browser = webdriver.Chrome(options=chrome_options)
【问题讨论】:
-
禁用杀毒软件。
-
我想到了,但您可以想象一种无需外部人为干预即可运行代码的方式吗?
-
感谢您的回答。我试过了,但没有用。
-
您可以将该机器上使用的配置文件添加到问题中吗?应该在
~/.config/google-chrome/还有,从命令行运行 chrome 会发生什么? -
对不起@JamesBurgess,我刚刚将浏览器更改为firefox以避免错误,它工作正常,我也无法获取配置文件。感谢您的帮助。
标签: python python-3.x selenium selenium-webdriver selenium-chromedriver