2016-08-17 54 views
-2

automationg登錄頁面我試圖登錄自動到Facebook。我試圖將硒連接到鉻驅動程序和IE驅動程序。但是當我執行代碼時,我得到一個沒有發現com.google.common.base.Function異常的類。我試圖谷歌它並下載com.google的jar文件並將其添加到eclipse。但是,然後我得到這條線上的IllegalStatementExceptionClassNotFoundException的同時使用硒

WebDriver wd=new InternetExplorerDriver(); 

這是代碼。

package com.automate; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.ie.InternetExplorerDriver; 
public class ConnectToUrl { 
    public static void main(String agrs[]){ 
     WebDriver wd=new InternetExplorerDriver(); 
     wd.get("https://accounts.google.com/ServiceLogin"); 
     wd.findElement(By.id("email")).sendKeys("Email"); 
     wd.findElement(By.id("pass")).sendKeys("password"); 
     wd.findElement(By.id("u_0_l")).click(); 
    } 
} 

什麼是錯誤以及如何解決它。

+0

您需要下載最新的iedriverserver.exe並啓動'InternetExplorerDriver(之前設置爲系統屬性IEdriverserver.exe從系統位置路徑可執行文件)' –

+0

在哪裏我可以找到這個IEdriverserver.exe? –

+0

轉到[此URL](http://www.seleniumhq.org/download/)並下載最新版本。 IEdriverServer這是適合你的操作系統... :) –

回答

0

你缺少的依賴,最有可能的谷歌的番石榴庫。如果你有一個基於Maven的項目,你可以包含以下依賴項。

<dependency> 
    <groupId>com.google.guava</groupId> 
    <artifactId>guava</artifactId> 
    <version>19.0</version> 
</dependency> 

至於非法的聲明之外,你應該參考這個問題:Not able to launch IE/Chrome from Selenium Webdriver

+0

沒有我不使用行家。所以我需要明確下載並將其添加到我的項目中。對? –

+0

這是正確的,不知道是否有番石榴等內部依賴關係,雖然,你將不得不將它們添加手動爲好。另外,對於第二個異常,webdriver.ie.driver應該先在線程中設置。希望能幫助到你 ! –

相關問題