package com.selenium.study; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; public class study3 { public static void main(String[] args) { //实例化一个对象Firefox WebDriver driver; System.setProperty("webdriver.firefox.bin","C:\\Program Files\\Mozilla Firefox\\firefox.exe"); driver = new FirefoxDriver(); String testurl="http://www.baidu.com"; driver.get(testurl); driver.quit(); } }
报错:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at com.selenium.study.study3.main(study3.java:9)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
检查你的火狐浏览器版本是否32,自动更新功能关闭掉,对应的selenium的jar包版本应该在24