selenium-打开IE浏览器遇到问题记录
【使用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();
}
}
}
【遇到的问题及其解决方案】:
解决办法:
IE安全保护都去掉:
internet选项——安全
internet-启用保护模式 勾去掉
本地internet-启用保护模式 勾去掉
可信站点-启用保护模式 勾去掉
除了上面的那几个,还需要在“受限制站点” 去除启用保护模式
selenium-打开IE浏览器遇到问题记录的更多相关文章
- selenium打开Chrome浏览器并最大化
#打开Chrome浏览器并放大 from selenium import webdriver def BrowserOpen(): driver = webdriver.Chrome(); drive ...
- Selenium+Java(二)Selenium打开IE浏览器
前言 已在Eclipse中配置完成Selenium的相关配置,不知道如何配置的可参考我的另一篇博文:https://www.cnblogs.com/yogouo/p/11946940.html 打开I ...
- 用Python+selenium打开IE浏览器和Chrome浏览器的问题
这几天在学Python+selenium自动化,对三大浏览器Firefox,Chrome和IE都做了尝试,也都分别下载了对应的webdriver,如:geckodriver.chromedriver. ...
- selenium打开chrome浏览器代码
import os from selenium import webdriver chromedriver = "C:\Program Files (x86)\Google\Chrome\A ...
- Python+selenium打开或关闭浏览器
Python+selenium打开或关闭浏览器 一.打开或关闭火狐浏览器 1. 初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打 ...
- Selenium打开IE报错“Protected Mode settings...”解决方法
最近在使用Selenium打开IE浏览器碰到以下报错:
- selenium在Eclipse中打开fireFox浏览器是报报错connect to host 127.0.0.1 on port 7055
1.相信很多同学刚接触selenium时,在Eclipse中打开fireFox浏览器是报报错: org.openqa.selenium.firefox.NotConnectedException: U ...
- 1 Selenium打开浏览器
[环境] Selenium3.0.1+Python3.6+unittest win7+IE10 1.打开FireFox浏览器 import unittest from selenium import ...
- selenium只打开一个浏览器窗口
from selenium.webdriver import Remote from selenium.webdriver.chrome import options from selenium.co ...
随机推荐
- 环境搭建 Hadoop+Hive(orcfile格式)+Presto实现大数据存储查询一
一.前言 Hadoop简介 Hadoop就是一个实现了Google云计算系统的开源系统,包括并行计算模型Map/Reduce,分布式文件系统HDFS,以及分布式数据库Hbase,同时Hadoop的相关 ...
- 【转】C#大文件读取和查询--内存映射
笔者最近需要快速查询日志文件,文件大小在4G以上. 需求如下: 1.读取4G左右大小的文件中的指定行,程序运行占用内存不超过500M. 2.希望查询1G以内容,能控制在20s左右. 刚开始觉得这个应该 ...
- windows下git识别大小写配置
默认情况下windows上的Git客户端,在文件名仅发生大小写改变时不会识别,提交后发现,gitlab上的文件名不会发生变化. 解决方法: 编辑 .git 中的config文件, 将 ignoreca ...
- ORACLE常见数据类型详解
1.字符类型 • CHAR:一个定长字符串,当位数不足自动用空格填充来达到其最大长度.如非NULL的CHAR(12)总是包含12字节信息.CHAR字段最多可以存储2,000字节的 信息. • VARC ...
- SIGABRT的可能原因
常见原因: 第三方库如glic检测到内部错误或者破坏约束条件 3种可能1.double free/free 没有初始化的地址或者错误的地址2.堆越界3.assert
- HUSTOJ搭建实录
要做一个MOOC平台,要求有在线编程功能,想偷个懒,于是用了HUSTOJ...... 系统:Ubuntu14.04 Kylin 步骤: 一.搭建服务器和相应环境 apache2: sudo apt-g ...
- 表示即将废弃一个方法,或不赞成使用的一个方法或属性或其它,关键词 deprecated
- Python中出现的异常
简单的写几种我知道的关于Python中出现的异常含义,希望大神批评指正,我只是学软件开发的菜鸟,前面的路还很长,我会努力学习! 什么是异常? 异常既是一个事件,该事件会在程序执行过程中发生,影响了程序 ...
- oracle建立数据库连接
除了全库拷贝,这个应该是oracle两个数据库之间进行数据迁移最快的方法了. CREATE PUBLIC DATABASE LINK zhengshi CONNECT TO 用户名 IDENTIFIE ...
- Perl爬取江西失信执行
#! /usr/bin/perl use strict; use Encode qw(encode decode); binmode(STDIN,":encoding(utf8)" ...