问题截图:

 

 

问题分析: 参考网址:https://blog.csdn.net/weixin_46739493/article/details/134163739

问题解决:

1、chrome版本为:版本 114.0.5735.199(正式版本);driver的版本为:114.0.5735.90; java-seleium版本为:4.0.0-rc-2

1         <dependency>
2             <groupId>org.seleniumhq.selenium</groupId>
3             <artifactId>selenium-java</artifactId>
4             <version>4.0.0-rc-2</version>
5         </dependency>

2、代码添加  options.addArguments("--remote-allow-origins=*");

public class TheOneTEST {
    @Test
    void firstSeleniumTest(){
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        WebDriver driver = new ChromeDriver(options);
        driver.get("https://www.baidu.com/?tn=15007414_15_dg");
    }

}

3、按我目前的资源配置,java-selenium需要升级到 4.10.0 版本才会没有问题;

依赖为:

1         <dependency>
2             <groupId>org.seleniumhq.selenium</groupId>
3             <artifactId>selenium-java</artifactId>
4             <version>4.10.0</version>
5         </dependency>

代码为:

1 public class TheOneTEST {
2     @Test
3     void firstSeleniumTest(){
4         WebDriver driver = new ChromeDriver();
5         driver.get("https://www.baidu.com/?tn=15007414_15_dg");
6     }
7 
8 }

另,具体的java-client版本参考:https://oss.sonatype.org/content/repositories/snapshots/org/seleniumhq/selenium/selenium-java/

 

posted on 2024-03-04 23:51  无知小笨鸟  阅读(497)  评论(0编辑  收藏  举报