selenium打开chrome时,出现 "您使用的是不受支持的命令行标记:--ignore-certificate-errors""...

本文介绍如何使用Selenium配置Chrome选项以消除不受支持的命令行标记提示,包括Python和Java两种语言实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过selenium模拟打开chrome窗口提示 "您使用的是不受支持的命令行标记:--ignore-certificate-errors"

#在Python程序前加上这段代码
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["ignore-certificate-errors"])
driver = webdriver.Chrome(chrome_options=options)
#在java程序前加上这段代码
ChromeOptions options = new ChromeOptions();
//通过配置参数禁止data;的出现
options.addArguments("--user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Default");
//通过配置参数删除“您使用的是不受支持的命令行标记:--ignore-certificate-errors。稳定性和安全性会有所下降。”提示
options.addArguments("--start-maximized",
"allow-running-insecure-content", "--test-type");
driver = new ChromeDriver(options);

 

转载于:https://my.oschina.net/fairy1674/blog/1236164

Aug 15, 2025 2:21:21 PM com.kms.katalon.core.logging.KeywordLogger startTest INFO: -------------------- Aug 15, 2025 2:21:22 PM com.kms.katalon.core.logging.KeywordLogger startTest INFO: START Test Cases/try Aug 15, 2025 2:21:24 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1 WARNING: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) Aug 15, 2025 2:21:24 PM com.kms.katalon.core.logging.KeywordLogger log SEVERE: ❌ Test Cases/try FAILED. Reason: org.openqa.selenium.remote.NoSuchDriverException: Unable to obtain: chromedriver, error Command failed with code: 65, executed: [--browser, chrome, --language-binding, java, --output, json] error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) Build info: version: '4.22.0', revision: 'c5f3146703' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.14' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverFinder.getBinaryPaths(DriverFinder.java:121) at org.openqa.selenium.remote.service.DriverFinder.getDriverPath(DriverFinder.java:55) at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:99) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:51) at try.run(try:25) at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194) at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119) at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448) at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439) at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418) at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410) at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:137) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:125) at TempTestCase1755238875241.run(TempTestCase1755238875241.groovy:25) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) Caused by: org.openqa.selenium.WebDriverException: Command failed with code: 65, executed: [--browser, chrome, --language-binding, java, --output, json] error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) Build info: version: '4.22.0', revision: 'c5f3146703' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.14' Driver info: driver.version: ChromeDriver at org.openqa.selenium.manager.SeleniumManager.runCommand(SeleniumManager.java:170) at org.openqa.selenium.manager.SeleniumManager.getBinaryPaths(SeleniumManager.java:247) at org.openqa.selenium.remote.service.DriverFinder.getBinaryPaths(DriverFinder.java:102) at org.openqa.selenium.remote.service.DriverFinder.getDriverPath(DriverFinder.java:55) at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:99) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:51) at Script1755238419595.run(Script1755238419595.groovy:25) ... 13 more Aug 15, 2025 2:21:24 PM com.kms.katalon.core.logging.KeywordLogger log SEVERE: ❌ Test Cases/try FAILED. Reason: org.openqa.selenium.remote.NoSuchDriverException: Unable to obtain: chromedriver, error Command failed with code: 65, executed: [--browser, chrome, --language-binding, java, --output, json] error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) Build info: version: '4.22.0', revision: 'c5f3146703' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.14' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverFinder.getBinaryPaths(DriverFinder.java:121) at org.openqa.selenium.remote.service.DriverFinder.getDriverPath(DriverFinder.java:55) at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:99) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:51) at try.run(try:25) at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194) at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119) at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448) at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439) at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418) at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410) at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:137) at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:125) at TempTestCase1755238875241.run(TempTestCase1755238875241.groovy:25) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) Caused by: org.openqa.selenium.WebDriverException: Command failed with code: 65, executed: [--browser, chrome, --language-binding, java, --output, json] error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) Build info: version: '4.22.0', revision: 'c5f3146703' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.14' Driver info: driver.version: ChromeDriver at org.openqa.selenium.manager.SeleniumManager.runCommand(SeleniumManager.java:170) at org.openqa.selenium.manager.SeleniumManager.getBinaryPaths(SeleniumManager.java:247) at org.openqa.selenium.remote.service.DriverFinder.getBinaryPaths(DriverFinder.java:102) ... 19 more Aug 15, 2025 2:21:24 PM com.kms.katalon.core.logging.KeywordLogger endTest INFO: END Test Cases/try
最新发布
08-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值