java.lang.NoSuchMethodError自动化测试问题selenium-java

在使用selenium-java进行火狐浏览器自动化测试时遇到java.lang.NoSuchMethodError。错误并非由Java版本引起,而是由于缺少com.google.common.collect包。引入该包后,问题得到解决。

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

今天使用selenium-java自动操作火狐浏览器,代码如下:

package com.stylefeng.guns.test;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class SeleniumTest
{
    public static void main(String[] args)
    {
        System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir") + "/src/main/resources/geckodriver.exe");
        System.setProperty("webdriver.firefox.bin","E://Program Files//Mozilla Firefox//firefox.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.baidu.com");
        driver.quit();
    }
}

运行后结果报错如下:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;
	at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$4(NewSessionPayload.java:199)
	at java.util.stream.ReferencePipeline$11$1.accept(Refer
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值