使用Selenium脚本时获取错误

使用Selenium脚本时获取错误,selenium,Selenium,尝试使用selenium运行脚本时出错 脚本代码: package automation; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class Gmail_Log

尝试使用selenium运行脚本时出错

脚本代码:

package automation;    
import org.openqa.selenium.By;    
import org.openqa.selenium.WebDriver;    
import org.openqa.selenium.WebElement;    
import org.openqa.selenium.firefox.FirefoxDriver;        
public class Gmail_Login {    
/**
8
* @param args
9
*/    
       public static void main(String[] args) {                          
// objects and variables instantiation    
              WebDriver driver = new FirefoxDriver();    
              String appUrl = "https://accounts.google.com";                          
// launch the firefox browser and open the application url    
              driver.get(appUrl);                          
// maximize the browser window    
              driver.manage().window().maximize();                          
// declare and initialize the variable to store the expected title of the webpage.    
              String expectedTitle = " Sign in - Google Accounts ";                          
// fetch the title of the web page and save it into a string variable    
              String actualTitle = driver.getTitle();                     
// compare the expected title of the page with the actual title of the page and print the result    
              if (expectedTitle.equals(actualTitle))    
              {    
                     System.out.println("Verification Successful - The correct title is displayed on the web page.");    
              }    
             else    
              {    
                     System.out.println("Verification Failed - An incorrect title is displayed on the web page.");    
              }             
// enter a valid username in the email textbox    
              WebElement username = driver.findElement(By.id("Email"));    
              username.clear();    
              username.sendKeys("TestSelenium");                          
// enter a valid password in the password textbox    
              WebElement password = driver.findElement(By.id("Passwd"));    
              password.clear();    
              password.sendKeys("password123");                          
// click on the Sign in button
           WebElement SignInButton = driver.findElement(By.id("signIn"));    
              SignInButton.click();                          
// close the web browser    
              driver.close();    
              System.out.println("Test script executed successfully.");                          
// terminate the program    
              System.exit(0);    
       }    
}
错误和例外:

Exception in thread "main" java.lang.NoClassDefFoundError: 
com/google/common/base/Function at 
automation.Gmail_Login.main(Gmail_Login.java:26)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function 
at java.net.URLClassLoader$1.run(Unknown Source) at 
java.net.URLClassLoader$1.run(Unknown Source) at 
java.security.AccessController.doPrivileged(Native Method) at 
java.net.URLClassLoader.findClass(Unknown Source) at 
java.lang.ClassLoader.loadClass(Unknown Source) at 
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at 
java.lang.ClassLoader.loadClass(Unknown Source) 

错误是什么,从哪里得到的?线程“main”java.lang.NoClassDefFoundError中的异常:com/google/common/base/Function at automation.Gmail_Login.main(Gmail_Login.java:26)由以下原因引起:java.lang.ClassNotFoundException:com.google.common.base.Function at java.net.URLClassLoader$1.run(未知源代码)at java.net.URLClassLoader$1.run(未知源)位于java.net.URLClassLoader.findClass(未知源)位于java.lang.ClassLoader.loadClass(未知源)位于sun.misc.Launcher$AppClassLoader.loadClass(未知源)位于java.lang.ClassLoader.loadClass(未知源)…1更多信息