【使用selenium打开IE浏览器步骤】:

  1、在IE浏览器上运行测试脚本,首先需要下载IEDriverServer.exe,放在IE浏览器的安装目录且同级目录下.

  2、参考代码如下:

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;import com.thoughtworks.selenium.webdriven.commands.WaitForCondition; public class SeleniumTest{
private WebDriver driver;
@Before
public void setUp(){
System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
System.out.println("打开浏览器");
} @Test
public void testLogic(){
System.out.println("打开——>百度一下");
driver.get("http://www.baidu.com/");
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement kw = wait.until(new ExpectedCondition<WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("kw"));
}
});
try {
if(kw!=null){
kw.sendKeys("selenium");
driver.findElement(By.id("su")).click();
Thread.sleep(1000);
}
System.out.println(driver.getCurrentUrl()); Thread.sleep(10000000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} @After
public void tearDown(){
if(driver!=null){
driver.quit();
}
}
}

【遇到的问题及其解决方案】:

1、报错:
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html 
解决方法:
   设置 system property:System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\IEDriverServer.exe");
 
2、报错:

org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.15 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'PC-201wegfer', ip: '10.1.9.173', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_43'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 

解决办法:

IE安全保护都去掉: 
internet选项——安全
internet-启用保护模式 勾去掉 
本地internet-启用保护模式 勾去掉 
可信站点-启用保护模式 勾去掉

除了上面的那几个,还需要在“受限制站点” 去除启用保护模式

selenium-打开IE浏览器遇到问题记录的更多相关文章

  1. selenium打开Chrome浏览器并最大化

    #打开Chrome浏览器并放大 from selenium import webdriver def BrowserOpen(): driver = webdriver.Chrome(); drive ...

  2. Selenium+Java(二)Selenium打开IE浏览器

    前言 已在Eclipse中配置完成Selenium的相关配置,不知道如何配置的可参考我的另一篇博文:https://www.cnblogs.com/yogouo/p/11946940.html 打开I ...

  3. 用Python+selenium打开IE浏览器和Chrome浏览器的问题

    这几天在学Python+selenium自动化,对三大浏览器Firefox,Chrome和IE都做了尝试,也都分别下载了对应的webdriver,如:geckodriver.chromedriver. ...

  4. selenium打开chrome浏览器代码

    import os from selenium import webdriver chromedriver = "C:\Program Files (x86)\Google\Chrome\A ...

  5. Python+selenium打开或关闭浏览器

    Python+selenium打开或关闭浏览器 一.打开或关闭火狐浏览器 1.       初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打 ...

  6. Selenium打开IE报错“Protected Mode settings...”解决方法

    最近在使用Selenium打开IE浏览器碰到以下报错:

  7. selenium在Eclipse中打开fireFox浏览器是报报错connect to host 127.0.0.1 on port 7055

    1.相信很多同学刚接触selenium时,在Eclipse中打开fireFox浏览器是报报错: org.openqa.selenium.firefox.NotConnectedException: U ...

  8. 1 Selenium打开浏览器

    [环境] Selenium3.0.1+Python3.6+unittest win7+IE10 1.打开FireFox浏览器 import unittest from selenium import ...

  9. selenium只打开一个浏览器窗口

    from selenium.webdriver import Remote from selenium.webdriver.chrome import options from selenium.co ...

随机推荐

  1. 环境搭建 Hadoop+Hive(orcfile格式)+Presto实现大数据存储查询一

    一.前言 Hadoop简介 Hadoop就是一个实现了Google云计算系统的开源系统,包括并行计算模型Map/Reduce,分布式文件系统HDFS,以及分布式数据库Hbase,同时Hadoop的相关 ...

  2. 【转】C#大文件读取和查询--内存映射

    笔者最近需要快速查询日志文件,文件大小在4G以上. 需求如下: 1.读取4G左右大小的文件中的指定行,程序运行占用内存不超过500M. 2.希望查询1G以内容,能控制在20s左右. 刚开始觉得这个应该 ...

  3. windows下git识别大小写配置

    默认情况下windows上的Git客户端,在文件名仅发生大小写改变时不会识别,提交后发现,gitlab上的文件名不会发生变化. 解决方法: 编辑 .git 中的config文件, 将 ignoreca ...

  4. ORACLE常见数据类型详解

    1.字符类型 • CHAR:一个定长字符串,当位数不足自动用空格填充来达到其最大长度.如非NULL的CHAR(12)总是包含12字节信息.CHAR字段最多可以存储2,000字节的 信息. • VARC ...

  5. SIGABRT的可能原因

    常见原因: 第三方库如glic检测到内部错误或者破坏约束条件 3种可能1.double free/free 没有初始化的地址或者错误的地址2.堆越界3.assert

  6. HUSTOJ搭建实录

    要做一个MOOC平台,要求有在线编程功能,想偷个懒,于是用了HUSTOJ...... 系统:Ubuntu14.04 Kylin 步骤: 一.搭建服务器和相应环境 apache2: sudo apt-g ...

  7. 表示即将废弃一个方法,或不赞成使用的一个方法或属性或其它,关键词 deprecated

  8. Python中出现的异常

    简单的写几种我知道的关于Python中出现的异常含义,希望大神批评指正,我只是学软件开发的菜鸟,前面的路还很长,我会努力学习! 什么是异常? 异常既是一个事件,该事件会在程序执行过程中发生,影响了程序 ...

  9. oracle建立数据库连接

    除了全库拷贝,这个应该是oracle两个数据库之间进行数据迁移最快的方法了. CREATE PUBLIC DATABASE LINK zhengshi CONNECT TO 用户名 IDENTIFIE ...

  10. Perl爬取江西失信执行

    #! /usr/bin/perl use strict; use Encode qw(encode decode); binmode(STDIN,":encoding(utf8)" ...