【使用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. excel 怎么去掉单元格中第一个空格或其他特定符号/Excel excel中批量去掉表格中首字母前的空格或特定符号

    =IF(FIND(" ",A160)>1,A160,MID(A160,FIND(" ",A160)+1,LEN(A160)-FIND(" &qu ...

  2. UVA 11809 - Floating-Point Numbers

    数学太渣了,这道题反复参考了大神的博客,算是看懂了吧.博客原文  http://blog.csdn.net/crazysillynerd/article/details/43339157 算是个数学题 ...

  3. vs2010 sql server 2008数据库管理界面安装

    http://jingyan.baidu.com/article/1e5468f928e106484961b7b0.html

  4. FreeMark学习(二)

    (1)用户定义指令 宏和变换器变量是两种不同类型的用户定义指令,它们之间的区别是宏是在模板中使用macro指令定义,而变换器是在模板外由程序定义,这里只介绍宏 基本用法 宏是和某个变量关联的模板片断, ...

  5. 19.dnw打不开

    用dnw.exe烧写文件时,突然出现电脑死机,重启后,dnw就打不开了,dnw.ini的原因,该文件在c盘目录下,只需要删除它,就可以继续使用dnw了.

  6. javascript数组的一些方法实例

    1 concat

  7. iOS内存管理

    iOS内存管理的方式是引用计数机制.分为MRC(人式引用计数)和ARC(自动引用计数). 为什么要学习内存管理? 内存管理方式是引用计数机制,通过控制对象的引用计数来实现操作对象的功能.一个对象的生命 ...

  8. SQL Server 2012 AlwaysOn 亲身实历记

    亲身经历的一个项目,老板忽然提出,对数据库的负债要实施分流,来个数据库一个负责读,而另一个负责写,后台是需要同步两个数据库的状态.找了很多的资料,发现新版的alwayson可以实现这个功能. 研读了a ...

  9. 关于<textArea>控件下显示不出其它控件

    今天在写页面控件时发现我添加一个<textarea>后,在其下方的控件都显示不出来了,后来发现我忘写结束标记</textarea>了 以后该写结束标记还要写啊!

  10. 第六百一十二、三、四、五天 how can I 坚持

    上火了啊..已经2017了,真快,人生只是一瞬间,到头来都是一场空. 2016年最后一天,很悲催,没赶上火车.还不能改签,哪能哪次都这么幸运,长记性了,下午到济南,看了看弟弟的房子,到挺不错,就是装修 ...