【基础】火狐和谷歌在Selenium3.0上的启动(二)
参考地址:http://www.cnblogs.com/fnng/p/5932224.html
https://github.com/mozilla/geckodriver
【火狐浏览器】
火狐浏览器的驱动下载地址:https://github.com/mozilla/geckodriver/releases
要求火狐浏览器版本:Support is best in Firefox 52.0.3 and onwards,最好是52及之后的版本
要求selenium版本:Selenium3.0及+
新建一个文件夹,如d:\seleniumdriver,将geckodriver.exe放置到该文件夹,再将d:\seleniumdriver配置到系统变量的Path里面
package ant_junit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestFirefox {
public static void main(String[] args) {
//如果火狐不是在默认目录下,需要这样设置一下火狐的路径,不然会报找不到火狐的错误
System.setProperty("webdriver.firefox.bin","D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
WebDriver dr = new FirefoxDriver();
dr.get("http://www.baidu.com");
dr.findElement(By.id("kw")).sendKeys("test");
dr.quit();
}
}
【谷歌浏览器】
谷歌浏览器的驱动下载地址:https://code.google.com/p/chromedriver/downloads/list,但是国内有时访问不了,可以去网上其他地址搜索下一个
要求谷歌浏览器版本:一般最新的都支持
新建一个文件夹,如d:\seleniumdriver,将chromedriver.exe放置到该文件夹,再将d:\seleniumdriver配置到系统变量的Path里面
package ant_junit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestChromeDriver {
public static void main(String[] args) {
//一般谷歌的安装都在默认目录下,当将chromedriver.exe配置到系统Path后,则可直接启动
WebDriver dr = new ChromeDriver();
dr.get("http://www.baidu.com");
dr.findElement(By.id("kw")).sendKeys("test");
dr.quit();
}
}
备注:
本人机器上测试成功的JDK版本:1.8
Selenium服务器版本:selenium-server-standalone-3.4.0.jar
【基础】火狐和谷歌在Selenium3.0上的启动(二)的更多相关文章
- appium在android7.0上无法启动问题
前言 由于最近很多android手机升级到7.0系统了,有些小伙伴的appium版本用的还是1.4版本,在运行android7.0的app自动化时候遇到无法启动问题:WebDriverExceptio ...
- 『心善渊』Selenium3.0基础 — 1、Selenium自动化测试框架介绍
目录 1.Selenium介绍 2.Selenium的特点 3.Selenium版本说明 4.拓展:WebDriver与Selenium RC的区别 5.Webdriver工作原理 1.Seleniu ...
- 『心善渊』Selenium3.0基础 — 24、Selenium的expected_conditions模块详细介绍
目录 1.EC模块介绍 2.EC模块常用类 3.EC模块的使用 4.EC模块综合使用 (1)title_is(title)示例 (2)presence_of_element_located(locat ...
- 1 selenium3.0.1无法打开火狐浏览器
[问题描述] 1.配置selenium3.0和java后,尝试打开火狐浏览器,提示缺少geckodriver驱动. [解决方案] 1.在http://www.seleniumhq.org/downlo ...
- selenium3.0不兼容火狐的解决方案
当直接调用火狐出现不兼容错误时,如何解决? 详看Message中提示:Expected browser binary location,but unable to find binary in def ...
- 『心善渊』Selenium3.0基础 — 22、使用浏览器加载项配置实现用户免登陆
目录 1.浏览器的加载项配置 2.加载Firefox配置 3.加载Chrome配置 1.浏览器的加载项配置 在很多情况下,我们在登录网站的时候,浏览器都会弹出一个是否保存登录账号的信息.如果我们选择保 ...
- CSS3_3D效果(IE10_火狐_谷歌)
好久没写博客了,看了下记录,上次最后写的最后一篇已经是8月1号了,最近有些小东西整理下,当巩固吧 废话少说,直奔本文主题 css3提供了很多新鲜好玩的东西,transform就是其中一个,可以进行 2 ...
- js 利用canvas + flv.js实现视频流 截屏 、本地下载功能实现,兼容火狐,谷歌;canvas截屏跨域问题,无音频视频流加载不显示问题
项目:物联网监控项目----后台视频流管理(前端实现视频截屏功能) 本文就不同视频源分情况展示: 1 本地视频(项目同目录视频)截屏(canvas.getContext("2d).drawI ...
- Selenium3.0 自动化测试
早在2013年的时候,Selenium官方宣布,Selenium新的版本会在圣诞节的时候发布.但是,他们并没有说哪一个圣诞节发布. 转眼的三年过去了,目前已经发布到Selenium3.0 beta4版 ...
随机推荐
- spring controller方法和jstl
1复杂类型查询:查询条件已经多于一个实体类中的属性 1)可以创建一个类用于组合查询条件 基础类 public class Items { private Integer id; private Str ...
- prometheus的agent 二次开发代码参考
import com.codahale.metrics.MetricRegistry;import io.prometheus.client.CollectorRegistry;import io.p ...
- 力扣(LeetCode)476. 数字的补数
给定一个正整数,输出它的补数.补数是对该数的二进制表示取反. 注意: 给定的整数保证在32位带符号整数的范围内. 你可以假定二进制数不包含前导零位. 示例 1: 输入: 5 输出: 2 解释: 5的二 ...
- leecode第八十八题(合并两个有序数组)
class Solution { public: void merge(vector<int>& nums1, int m, vector<int>& nums ...
- x1c 6th usb-c 接口灯常亮,电源无法充电
症状: 左侧能充电的那个usb-c 红灯始终常亮.拔下电源线也亮着. 系统里电源是始终显示正在充电,即使拔掉外接电源也显示连着外接电源正在充电! ——最吓人的是,用U盘启动进PE,想重装win10,结 ...
- Ruby 基础教程 第一部分总结
第一部分:Ruby 初体验 第一章: Ruby 初探 前言 开头的这一章节讲了一些十分基础的内容,重要的几个话题有: ruby 命令的执行方法 对象.方法的概念 常见的打印方法 ruby 命令的执行方 ...
- String的intern()方法和java关键字、保留字
String s1 = new StringBuilder("hel").append("lo").toString(); //hello System.out ...
- every day a practice —— morning(4)
If there’s one thing New Yorkers love more than discovering a new secret remedy, it’s telling other ...
- codeforces 848B Rooter's Song 思维题
http://codeforces.com/problemset/problem/848/B 给定一个二维坐标系,点从横轴或纵轴垂直于发射的坐标轴射入(0,0)-(w,h)的矩形空间.给出点发射的坐标 ...
- Python Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat)
在windows 平台下,当python使用以下方式安装时,可能出现以下错误: > python setup.py install error: Microsoft Visual C++ 10. ...