我将 selenium 与 python 和 chromium/chromedriver 结合使用。我想删除传递给 chrome 的开关(例如 --full-memory-crash-report),但到目前为止我只能找到如何添加更多开关。
我当前的设置:
from selenium import webdriver
driver = webdriver.Chrome(executable_path="/path/to/chromedriver")
driver.get(someurl)
据我所知,这可以用来添加参数:
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--some-switch")
driver = webdriver.Chrome(chrome_options=chrome_options)
那么,我该如何摆脱默认参数或清除所有默认参数并仅传递自定义列表?
最佳答案
它帮助了我:
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["test-type"])
options.add_argument("--incognito")
driver = webdriver.Chrome(options=options)
关于python - 删除由 selenium/chromedriver 传递给 chrome 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16529524/