java.lang.NoClassDefFoundError:com / google / common / base / Function

编程入门 行业动态 更新时间:2024-10-23 17:25:39
本文介绍了java.lang.NoClassDefFoundError:com / google / common / base / Function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Selenium Web驱动程序的初学者。致电driver时遇到一些问题。我附上了程序和错误,供您参考。 1)我已经尝试使用独立jar和单个jar文件 2)在环境变量中也正确设置了路径。

I am a beginner in Selenium web driver. I am getting some issues while calling driver.I am attaching the program and error for your reference. 1) I have already tried with standalone jar and individual jar files 2) Path also set correctly in environment variables.

我正在使用JDK

如果可以的话,请帮帮我。尝试了互联网上提到的很多方法。仍然无法确定是什么确切的问题。当我创建一个Testng示例程序时,就会在特定的一天抛出该错误。

Please help me if you can..Tried so many ways which is mentioned on internet.Still couldn't identify what is the exact issue. This error started to throw on a particular day when I created a Testng sample program.

import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; public class Sample22 { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver",//E://share//geckodriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); //WebDriver driver1 = new MarionetteDriver(capabilities); WebDriver driver1 = new FirefoxDriver(); } }

错误为

线程 main中的异常java.lang.NoClassDefFoundError:com / google / common / base / Function在Sample22.main(Sample22。 java:12)由以下原因引起:java.lang.ClassNotFoundException:com.googlemon.base.Function at java.URLClassLoader.findClass(Unknown Source)at java.lang.ClassLoader.loadClass(Unknown Source)at java.lang .ClassLoader.loadClass(Unknown Source)...另外1个

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function at Sample22.main(Sample22.java:12) Caused by: java.lang.ClassNotFoundException: com.googlemon.base.Function at java.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more

推荐答案

照顾你很多事情r代码如下:

You need to take care of lot of things in your code as follows:

  • 当您的代码位于 Java , System.setProperty 行期望 value 字段包含单个正斜杠 / 或反斜杠 \\ 。
  • 值参数需要作为 String 传递给双引号 ...
  • 如果您正在使用 DesiredCapabilities 类,请记住传递 DesiredCapabilities 在启动 WebDriver 实例时将类作为参数。
  • 如果使用的是 import org.openqa .selenium.remote。*; 确保已添加最新的 selenium-server-standalone.jar 作为外部Jar 。
  • 启动浏览器会话后,导航至某个网址以确认是否建立了成功的会话。
  • 您的最终代码块将如下所示:

  • When your code is in Java, System.setProperty line expects the value field to contain either single forward slashes / or escaped backward slashes \\.
  • The value parameter needs to to be passed as a String within double quotes "..."
  • If you are using DesiredCapabilities Class, remember to pass the instance of the DesiredCapabilities Class as an argument when you initiate the WebDriver instance.
  • If you are using import org.openqa.selenium.remote.*; ensure that you have added the latest selenium-server-standalone.jar as an External Jar.
  • Once you initiate a browser session navigate to some url to confirm if a successful session is established.
  • Your final code block will look like: import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; public class Sample22 { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "E:\\share\\geckodriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(capabilities); driver.navigate().to("google"); } }

  • 更多推荐

    java.lang.NoClassDefFoundError:com / google / common / base / Function

    本文发布于:2023-05-25 10:55:29,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/226622.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:NoClassDefFoundError   lang   java   google   Function

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!