我的代码在某些 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)
在实例化 webdriver 之前,您可以显式地将隐身标志传递给 chrome。
chrome_options.add_argument('-incognito')
我怀疑这只发生在已经在 chrome 上登录的机器上。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)