1

或者任何人都知道将 IE 用于 selenium webdriver 的任何不同解决方案。我的代码如下

package backOffice;  
import java.io.File;  
import org.openqa.selenium.By;  
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.WebElement;  
import org.openqa.selenium.chrome.ChromeDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;  
import org.openqa.selenium.remote.DesiredCapabilities;    
import com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName;    
import bsh.ParseException;  

public class Time    
{   
   private WebDriver driver;    
   private String baseUrl= "http://www.google.co.in/";      
   public static void main(String args[]) throws InterruptedException   
  {                 
     Time tm=new Time();        
     tm.trial();    
  }     

private void trial() throws InterruptedException    
 {          
    File file = new File("C:/Documents and Settings/Administrator/Desktop/32-      bit_IEDriverServer_Win32_2.31.0/IEDriverServer.exe");        
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();                caps.setCapability("ignoreZoomSetting", true);        
    driver=new InternetExplorerDriver(caps);        
    driver.get(baseUrl + "/");                          
    driver.findElement(By.id("gbqfq")).clear();         
    driver.findElement(By.id("gbqfq")).sendKeys("harshal kakade");          
    driver.findElement(By.id("gbqfb")).click();
    driver.findElement(By.linkText("Harshal Kakade - India | LinkedIn")).click ();      
  }  
 }

谢谢,

哈沙尔。

4

1 回答 1

0

尝试查看互联网选项-> 安全性并取消选中“启用保护模式”。可能有问题。

于 2014-01-10T13:27:46.007 回答