问题:selenium-java版本为4.1.4、4.8.2 + Java 8 运行时报Invalid Status code=403 text=Forbidden

 运行代码:

public class RemoteTest {
    public ChromeOptions options ;
    public WebDriver driver;
    @Test
    public void  remoteTest(){

        options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        options.setExperimentalOption("debuggerAddress","localhost:9222");
        driver  = new ChromeDriver(options);
        driver.get("https://www.baidu.com");
        driver.findElement(By.id("kw")).sendKeys("李晓明");
        driver.findElement(By.id("su")).click();
    }

}

报错如下:

解决办法:(参考:https://stackoverflow.com/questions/75680149/unable-to-establish-websocket-connection/75703971#75703971)

目前我的浏览器是 123.0.6312.86 + jdk 1.8 

感觉降低selenium-java版本或降低浏览器的版本号(如 105)都不会出现问题

 

posted on 2024-04-10 22:44  无知小笨鸟  阅读(203)  评论(0编辑  收藏  举报