5--Selenium环境准备--firefox与geckodriver
selenium2时打开firefox浏览器是不需要安装firefoxdriver的,但是selenium3不支持向前支持火狐浏览器了,40以后版本的火狐,运行会出现问题。
1、下载geckodriver
https://github.com/mozilla/geckodriver/releases
chrome浏览器需要下载chromedriver
然后在代码中添加即可
public class lesson4 {
@Test
public void BrowserTest() throws InterruptedException{
/*----------------------------lesson1--------------------打开浏览器*/
//chrome浏览器需要添加chromedriver,ie需要增加internateExplorerdriver
//而selenium2中firefox无需,selenium3中需要添加geckodriver
System.setProperty("webdriver.gecko.driver", "G:/Testing/selenium/geckodriver.exe");
//打开浏览器
WebDriver dr=new FirefoxDriver();
Thread.sleep(2000);
/*----------------------------lesson2--------------------------*/
//浏览器最大化
dr.manage().window().maximize();
//打开百度
dr.get("https://www.baidu.com/");
//获取打开页面的title,并判断title是否正确
System.out.println("the title is:"+dr.getTitle());
System.out.println("Current url is:"+dr.getCurrentUrl());
//判断页面跳转的方式:打开一个url,等待3s,在获取currenturl,判断,不相等则发生跳转成功
//判断页面跳转的方式:通过页面的title判断
/*----------------------------lesson3--------------------------*/
//自定义profile
//关闭浏览器:close--只是关闭浏览器,但是服务不停,quit服务也会停掉,推荐quit
dr.quit();
}
参考资料:https://blog.csdn.net/jinhe123/article/details/69946234
5--Selenium环境准备--firefox与geckodriver的更多相关文章
- 在Centos7下docker配置自动化环境镜像(python3.7+selenium 3.11+firefox 62+geckodriver 0.21)
最近在学习Docker,准备做自动化测试代码集成的功能.如下文章的前提是已经安装好linux系统,且成功安装好Docker. 接下来我会按步骤一步一步的对自动化需要的一些环境进行安装,如果没有特别说明 ...
- python selenium环境配置Firefox和Chrome
1.下载Selenium库,可以使用pip install selenium https://pypi.python.org/pypi/selenium/ 2.下载驱动 Chrome: https:/ ...
- 【selenium 3】 Mac 下测试环境搭建 Firefox 47+ gecko driver Mac
错误代码如下:File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriv ...
- 篇5 python自动化测试应用-Selenium环境篇
篇5 python自动化测试应用-Selenium环境篇 --lamecho 1.1概要 大家好!我是lamecho(辣么丑),从本篇开始我将开始 ...
- Python3+Selenium环境配置
一.所需工具 1.Python3.6安装包 2.Selenium安装包(selenium-server-standalone-3.8),如果是Python3的话可以不用下载selenium压缩包,Py ...
- windows下使用selenium报错selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH
问题 :执行程序代码报错: WebDriverException:Message:'geckodriver'executable needs to be in Path 或者 selenium.com ...
- python+selenium 环境配置
配置环境: python:3.5 selenium:3.3.0 安装方式:python pip install -u selenium windows: 10 firefox:52 因为firefox ...
- 搭建Selenium环境
1.下载并安装Python 此学习笔记使用Python语言进行开发,所以我已经安装了Python环境,我的Python版本为3.5.2: 2.安装selenium 因为我使用的Python3版本,在该 ...
- selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 错误处理方法
首次使用selenium webdriver,webdriver.Firefox() 报错selenium.common.exceptions.WebDriverException: Message: ...
随机推荐
- vue虚拟DOM源码学习-vnode的挂载和更新流程
代码如下: <div id="app"> {{someVar}} </div> <script type="text/javascript& ...
- 在js中if条件为null/undefined/0/NaN/""表达式时,统统被解释为false,此外均为true
Boolean 表达式 一个值为 true 或者 false 的表达式.如果需要,非 Boolean 表达式也可以被转换为 Boolean 值,但是要遵循下列规则: 所有的对象都被当作 true. 当 ...
- nodejs 修改端口号 process.env.PORT(window环境下)
各个环境下,nodejs设置process.env.PORT的值的命令,如下1.linux环境下: PORT= node app.js 使用上面命令每次都需要重新设置,如果想设置一次永久生效,使用下面 ...
- openssl修改版本号
1.查看当前openssl版本号 openssl version 2.查看openssl所在位置 which openssl 3.查看保存版本号的libcrypto.so所在位置 ldd /usr/b ...
- QT和JS的互相调用例子
转自: http://blog.163.com/qimo601@126/blog/static/15822093201682185819623/ Qt 4.8.4 感谢原作者,我只转载. 看看作者如何 ...
- 把旧系统迁移到.Net Core 2.0 日记(4) - 使用EF+Mysql
因为Mac 不能装SqlServer, 所以把数据库迁移到MySql,然后EntityFramework要改成Pomelo.EntityFrameworkCore.MySql 数据库迁移时,nvarc ...
- summary_22rd Nov 2018
一. 列表:记录同种属性的多个值 定义:在[]中用逗号分隔开多个任意的值 类型转换:L=list( ) 括号中的内容必须是可迭代类型,包括字符串,列表,字典等 常用操作和内置方法: 1.按照索引位置 ...
- Chrome使用的plugin
Chrome使用的plugin 翻译 google翻译 youlict划词翻译 书签 查询书签 neater bookmarks 博客园收藏网页 书签保存 bookmark sysnc ...
- JS--script标签注意细节
1)在使用<script>标签嵌入js代码时,记住不要在代码中的任何地方出现</script>字符串.例如: <script type="text/javasc ...
- mac 安装Seaslog扩展及SeasLogger应用
首先下载 http://pecl.php.net/package/SeasLog 下载最新解压 cd /SeasLog-2.0.2/SeasLog-2.0.2/ phpize ./configure ...