Internet explorer 用于IE的Selenium脚本

Internet explorer 用于IE的Selenium脚本,internet-explorer,selenium-rc,Internet Explorer,Selenium Rc,我在运行Internet Explorer 9的selenium脚本时遇到此错误 Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The

我在运行Internet Explorer 9的selenium脚本时遇到此错误

 Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information); duration or timeout: 193 milliseconds

有一个关于此问题的错误报告:

如果在所有Internet Explorer区域(IE设置中的“安全”选项卡)中启用“保护模式”,我相信问题已经解决


不要通过代码来完成,这就是原因

HSSFWorkbook wb=新的HSSFWorkbook(文件);-。xsl文件

    XSSFSheet sh = wb.getSheet("Sheet1");
HSSFSheet sh=wb.getSheet(“Sheet1”);//表1需要替换为实际选项卡名称 System.out.println(sh.getRow(0.getCell(0.getStringCellValue());//给出了数据。需要相应地更新行和列编号

    driver.get("url");
    //Get the title of the application
    String strTitle = driver.getTitle();
    System.out.println("Title of the page:"+strTitle);
    
    //No of elements 
    List<WebElement> listElements = driver.findElements(By.xpath("")); // Use findelemet'S' not findelement
    System.out.println(listElements.size());
    
}
@Parameters ({"Type","Name"}) // Add name of parameters added in testng.xml and give name over here and do the same naming in method
@Test
public void testMethod2(String strType, String strName) {
    System.out.println(strType); //Gives the parameter value specified in testng.xml
}

@AfterTest
public void testTearDown() {
    
}

@AfterMethod
public void methodTearDown() {
    
}

@AfterSuite
public void suiteTearDown() {
    driver.close();
}
driver.get(“url”);
//获取应用程序的标题
String strTitle=driver.getTitle();
System.out.println(“页面标题:+strTitle”);
//元素数量
List listElements=driver.findElements(By.xpath(“”);//使用findelement的“非findelement”
System.out.println(liselements.size());
}
@Parameters({“Type”,“Name”})//添加testng.xml中添加的参数的名称,在这里给出名称,并在方法中进行相同的命名
@试验
公共void testMethod2(字符串strType、字符串strName){
System.out.println(strType);//给出testng.xml中指定的参数值
}
@事后
公共void testTearDown(){
}
@后置法
public void methodTearDown(){
}
@事后
public void suitetardown(){
driver.close();
}

感谢它的工作,但出现了另一个异常:org.apache.http.impl.client.DefaultRequestDirector tryExecute信息:处理请求时捕获的I/O异常(java.net.SocketException):软件导致的连接中止:recv失败9月30日,2011年1:49:35 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute信息:重试请求如果您遇到另一个异常,您应该在selenium网站上打开一个错误报告。+1。这对我来说非常有效,如果您想移植测试用例,最好是通过编程来实现,而不是通过更改浏览器设置来实现。文件scrFile=((TakesScreenshot)driver)。getScreenshotAs(OutputType.File);//现在,您可以使用它执行任何需要执行的操作,例如复制某处的FileUtils.copyFile(scrFile,new File(“c:\\tmp\\screenshot.png”);driver.switchTo().alert().disease();driver.switchTo().alert().accept();driver.switchTo().alert().getText();driver.switchTo().alert().sendKeys(“文本”);TakesScreenshot scrShot=((TakesScreenshot)webdriver)//调用getScreenshotAs方法创建图像文件SrcFile=scrShot.getScreenshotAs(OutputType.file)//将图像文件移动到新的目标文件DestFile=新文件(fileWithPath)//复制目标文件utils.copyFile(SrcFile,DestFile)处的文件;@Test@Parameters({“username”,“password”})public void testcase2(字符串用户名,字符串密码){driver.findelelement(By.xpath(“”)).sendKeys(username);driver.findelelement(By.xpath(“”).sendKeys“password”);/@BeforeSuite/@beforestclass/@beforethod/@Test/@AfterMethod/@AfterClass/@AfterTest/@AfterSuite
    XSSFSheet sh = wb.getSheet("Sheet1");
    driver.get("url");
    //Get the title of the application
    String strTitle = driver.getTitle();
    System.out.println("Title of the page:"+strTitle);
    
    //No of elements 
    List<WebElement> listElements = driver.findElements(By.xpath("")); // Use findelemet'S' not findelement
    System.out.println(listElements.size());
    
}
@Parameters ({"Type","Name"}) // Add name of parameters added in testng.xml and give name over here and do the same naming in method
@Test
public void testMethod2(String strType, String strName) {
    System.out.println(strType); //Gives the parameter value specified in testng.xml
}

@AfterTest
public void testTearDown() {
    
}

@AfterMethod
public void methodTearDown() {
    
}

@AfterSuite
public void suiteTearDown() {
    driver.close();
}
File src=new File("filepath/excelsheetname.xlsx");

// load file
FileInputStream fis=new FileInputStream(src);

// Load workbook
XSSFWorkbook wb=new XSSFWorkbook(fis);

// Load sheet- Here we are loading first sheetonly
XSSFSheet sh1= wb.getSheetAt(0);

// getRow() specify which row we want to read.
// and getCell() specify which column to read.
// getStringCellValue() specify that we are reading String data.

System.out.println(sh1.getRow(0).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(0).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(1).getCell(1).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(0).getStringCellValue());
System.out.println(sh1.getRow(2).getCell(1).getStringCellValue());