我是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:
您的最终代码块将如下所示:
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
发布评论