当前位置: 首页 > 知识库问答 >
问题:

ubuntu中的Selenium java错误com/google/common/collect/immutableMap

曾泳
2023-03-14
package test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class App {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "/home/bopsi/webdriver/chromedriver/2.40/chromedriver");
        WebDriver driver = new ChromeDriver();

        String baseUrl = "http://demo.guru99.com/test/newtours/";
        String expectedTitle = "Welcome: Mercury Tours";
        String actualTitle = "";

        driver.get(baseUrl);

        actualTitle = driver.getTitle();

        if (actualTitle.contentEquals(expectedTitle)) {
            System.out.println("Test Passed!");
        } else {
            System.out.println("Test Failed");
        }

        driver.close();
    }
}
<dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.13.0</version>
        </dependency>
</dependencies>

它给了我以下错误-

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
    at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:250)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:98)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:91)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at org.qlikhain.auto_liker.App.main(App.java:11)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 5 more

我双重检查了驱动程序路径和mase确定它存在于文件夹中。同样的代码在我的Windows10系统中工作。在这两个系统中,我都使用了chrome v68、chromedriver 2.40和jdk 1.8。知道为什么它在Ubuntu中不起作用吗?我错过了什么重要的步骤吗?

共有1个答案

郏景澄
2023-03-14

文件com/google/common/collection/immutablemap很可能已损坏。

我已经提供了如何解决这个问题的解决方案:

Java.lang.NoClassDeffounderRror:在Java Selenium中使用带有Maven依赖项的WebDriver时,com/google/common/collection/immutableMap

 类似资料:
  • 亲爱的硒专家, 我遇到了来自JPA 2.0程序的以下运行时错误,由于某种原因,它似乎与Firefox配置文件有关: 我将Firefox保持在版本15,这样它就可以被Selenium Webdriver支持,但是我怀疑这个问题与不能读取配置文件目录有关。 你的帮助将是非常恰当的。 非常感谢, 乔治

  • 好的,我正在使用eclipse-neon-Client-combined-3.1.0-nodeps。firefox安装程序39.0的jar 这是我的代码 这就是错误 线程“main”java中出现异常。lang.NoClassDefFoundError:com/google/common/base/Function at T1。main(T1.java:12)由:java引起。lang.Class

  • 问题内容: 当我执行以下代码时: 我遇到以下错误: `错误:[Ljava.lang.StackTraceElement; @ 80f4cb 线程“主”中的异常java.lang.NoClassDefFoundError:com / google / common / base / Function` 有人可以帮我找到解决方案或原因吗? 问题答案: 我遇到了同样的问题,最后我发现我忘记添加selen

  • 我目前正在做一个应用程序,其中包含googlemap。下面给出了该xml文件的代码,但在图形布局中显示了一个错误 “缺少样式。为此布局选择的主题正确吗?使用布局上方的主题组合框选择其他布局,或修复主题样式引用。 xml和清单文件如下所示 manifest.xml

  • 正如标题所强调的,我在Ubuntu的Java编译器方面遇到了麻烦。我重新安装了操作系统。几个月前,在卸载Ubuntu之前,Eclipse的Java编译器就像一个魅力一样工作。我按照同样的步骤...: 安装OpenJDK Java 7 Runtime(Ubuntu上最新的官方JDK,我以前使用过); 安装最新版本的Eclipse; 从我的主文件夹、我的文档、桌面、单独的HDD和单独的分区运行它...

  • 我试图使用Xpath立即从活动元素获取数据,但当我运行该项目时,我遇到了这个错误 线程“main”组织中出现异常。openqa。硒。StaleElementReferenceException:stale元素引用:元素未附加到页面文档