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 ...
随机推荐
- xampp 配置虚拟主机
1.安装好xampp后 2.找到安装目录 apache目录--conf目录--extra目录--httpd-vhosts.conf文件(用记事本或者别的编辑器打开) 文件最后添加代码 <Virt ...
- JQuery lhgdialog使用
jQuery方式调用 J ); testDG4.SetPosition( 'center', 'center' );}; var testDG4 = J('#btn26').dialog({ id:' ...
- Axure 7.0 正式版 + 汉化包 安装
详情如下: Axure 7.0 正式版终于发布了,现在提供简体中文版给大家使用. Axure 7.0 正式版: 链接: http://pan.baidu.com/s/1kV4OJ47 提取密码: be ...
- js 小工具-- 按长度截取字符串
function cutstr(str,len){ var temp; var icount = 0; var stren = ""; //这段正则表示匹配所有汉字以及全角字符 v ...
- js中function参数默认值
--在dreamweaver做网站时,函数定义是在一个*.js文件中,其中定义了一个func,有四个参数,function func(string1,url,flag,icon),然后在另一个asp中 ...
- IE6-8下自定义标签的表现
IE6-8是支持自定义标签,但只支持<xxx-yyy />这样的形式,它会翻译成<xxx-yyy></xxx-yyy> 如果你想内套子标签会失败, <ms-k ...
- matlab 去掉字符串前后的空格
strtrim 从字符串,删除开头和结尾的空白 句法 S = strtrim(STR) C = strtrim(CSTR)
- solrCloud+tomcat+zookeeper集群配置
solrcolud安装solrCloud+tomcat+zookeeper部署 转载请出自出处:http://eksliang.iteye.com/blog/2107002 http://eksli ...
- RequireJS 基础(一)
RequireJS由James Burke创建,他也是AMD规范的创始人. RequireJS会让你以不同于往常的方式去写JavaScript,你将不再使用script标签在HTML中引入JS文件,以 ...
- linux下mv命令使用方法
1.作用mv命令来为文件或目录改名或将文件由一个目录移入另一个目录中.该命令等同于DOS系统下的ren和move命令的组合.它的使用权限是所有用户.2.格式mv [options] 源文件或目录 目标 ...