Chrome更新后Selenium调试模式下403错误求助
Chrome更新后Selenium连接报错(403 Forbidden)求助
这是我首次发帖求助。Chrome更新后,不少开发者都碰到了相关错误,我作为编程新手也中招了。目前遇到org.openqa.selenium.remote.http.WebSocket$Listener onError错误,同时有“WARNING: Invalid Status code=403 text=Forbidden”提示,试过多种方案都没用,求各位帮忙。
我的Maven依赖配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.rcv</groupId> <artifactId>SeleniumTraining</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.8.0</version> </dependency> <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --> <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>3.8.1</version> </dependency> </dependencies> </project>
初始代码片段
String report = "Report of Anna's DemoAutomation:"; static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd HH:mm"); String now = formatter.format(ZonedDateTime.now()); static ChromeOptions options; static WebDriver driver; static String variablesHere = "variablesHere"; public void setUp() { options = new ChromeOptions().setExperimentalOption("debuggerAddress", "localhost:9014"); options.addArguments("--disable-notifications"); options.addArguments("--remote-allow-origins=*"); driver = new ChromeDriver(options); report(report); report("Time started: " + now + "\n"); System.setProperty("webdriver.chrome.driver", "C:\\Users\\Anna\\Downloads\\chromedriver_win32 (1)\\chromedriver.exe"); driver.manage().window().maximize(); driver.get("https://google.com");
已尝试的解决方案
- 添加
options.addArguments("--remote-allow-origins=*")参数 - 引入以下Maven依赖:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-http-jdk-client</artifactId> <version>4.5.0</version> </dependency>
- 设置系统属性:
System.setProperty("webdriver.http.factory", "jdk-http-client");
以上方法均无效,仍然出现403错误,恳请各位提供解决思路。
内容的提问来源于stack exchange,提问作者AnnaBanana
相关产品推荐
相关产品推荐

