【使用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. MFC 编辑框中字体大小改变,行高不能改变,只能显示一半的问题,已解决。

    CKagulaCEdit是CEdit的一个继承类,m_edit的CKagulaCEdit类型的一个变量 调用的时候,是这样的: 编辑框中字体大小改变,行高不能改变,只能显示一半的问题,问题如下: 这时 ...

  2. iOS平台使用陀螺仪传感器

    在移动端开发过程中,有时候会用到陀螺仪传感器获取当前手机的姿态,下面给出iOS端如何获取陀螺仪姿态数据的代码: //根据陀螺仪的四元数转换为矩阵 + (GLKMatrix4)calculateMatr ...

  3. IT行业找工作难

    1.面试官主要看年龄,年龄小,技术再牛也不给你面试机会. 2.现在培训机构太多了,不管多大岁数的人看见这行业赚钱就立刻辞职去培训. 3.刚培训出来的能找到2w!!有的老板面试只看工作经验,不管之前干什 ...

  4. ppt 数组课后作业

    任务要求:随机生成10个数,填充一个数组,然后用消息框显示数组内容,接着计算数组元素的和,将结果也显示在消息框中. 设计思路:建一个数组,在for语句中将随机数存入数组中,然后每生成一个数就进行相加, ...

  5. redis和memcached缓存

    memcached memcache开源的,高性能,高并发分布式内存缓存系统,天生支持集群 memcached下载地址: http://memcached.org/downloads python实现 ...

  6. Java程序员必须知道的10个调试技巧

    调试可以帮助识别和解决应用程序缺陷,在本文中,将使用大家常用的的开发工具Eclipse来调试Java应用程序. 但这里介绍的调试方法基本都是通用的,也适用于NetBeans IDE,我们会把重点放在运 ...

  7. make[2]: *** No rule to make target `/root/.pyenv/versions/anaconda3-2.4.0/lib/libpython3.5m.so', needed by `evaluation.so'. Stop.

    当出现No rule to make target ,肯定是Makefile有问题. 有的makefile是脚本生成的,你得看脚本的配置文件对不对. 我的是这个脚本生成的.发现是Pythondir的配 ...

  8. Tomcat和JavaWeb笔记

    <iframe src="http://www.xmind.net/embed/XFXh" width="900px" height="540p ...

  9. android sqlite datetime demo

    @Override public void onCreate(SQLiteDatabase db) { String sql="create table user ( username va ...

  10. php面向对象之final的应用

    final从英文字面上很容易理解,翻译成中文就是“最终的”之意.在php面向对象编程中,final的应用主要有两个作用:   1.使用final修饰的类,该不能被继承   01 <?php 02 ...