Selenium webdriver Java firefox 路径设置问题
问题: Cannot find firefox binary in PATH. Make sure firefox is installed.
原因:selenium找不到Firefox浏览器。
方法一:重新安装Firefox在默认路径下。
方法二:直接用System.setProperty方法设置webdriver.firefox.bin的值
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirefoxDirectory {
WebDriver driver=null;
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.firefox.bin", "D:\\firefox\\firefox.exe");
driver=new FirefoxDriver();
driver.get("http://www.baidu.com");
driver.manage().window().maximize();
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void test() throws InterruptedException {
//test content
}
}
方法三:利用setCapability进行设置
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities; public class FirefoxDirectory {
WebDriver driver=null; @Before
public void setUp() throws Exception {
DesiredCapabilities ffcapability = DesiredCapabilities.firefox();
ffcapability.setCapability("firefox_binary", "D:\\firefox\\firefox.exe");
driver=new FirefoxDriver(ffcapability);
driver.get("http://www.baidu.com");
driver.manage().window().maximize();
} @After
public void tearDown() throws Exception {
driver.quit();
} @Test
public void test() throws InterruptedException {
//test content
}
}
方法四:利用FirefoxBinary进行设置
import java.io.File;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver; public class FirefoxDirectory {
WebDriver driver=null; @Before
public void setUp() throws Exception {
File file = new File("D:\\firefox\\firefox.exe");
FirefoxBinary firefoxbin = new FirefoxBinary(file);
driver=new FirefoxDriver(firefoxbin,null);
driver.get("http://www.baidu.com");
driver.manage().window().maximize();
} @After
public void tearDown() throws Exception {
driver.quit();
} @Test
public void test() throws InterruptedException {
//test content
}
}
Selenium webdriver Java firefox 路径设置问题的更多相关文章
- Selenium Webdriver java 积累一
Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriv ...
- [selenium webdriver Java]常用api
1. 获取元素文本 WebElement类的getText()方法返回元素的innerText属性.所以元素里如果有子节点一样也会被返回出来.如下所示 public class GetText { @ ...
- Selenium webdriver firefox 路径设置问题
问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...
- Selenium webdriver Java 高级应用
对于这一段还蛮有感慨的,只想说,代码还是需要自己去敲的. 1. 改变用户代理 import org.junit.AfterClass; import org.junit.BeforeClass; im ...
- Selenium WebDriver java 简单实例
开发环境 JDK 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse: 下载地址:http ...
- Selenium webdriver Java 操作IE浏览器
V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...
- Selenium webdriver Java 开始
最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirv ...
- [selenium webdriver Java]隐式的等待同步
Selenium WebDriver提供了隐式等待来同步测试.当使用了隐式等待执行测试的时候,如果WebDriver没有在DOM中找到元素,将继续等待,超出设定时间后,抛出找不到元素异常 即,当元素没 ...
- Java 学习笔记 (二) Selenium WebDriver Java 弹出框
下面这段实例实现了以下功能: 1. profile使用用户本地电脑上的 (selenium 3有问题.因为selenium 3把profile复制到一个temp文件夹里,但并不复制回去.所以每次打开仍 ...
随机推荐
- 区块链开发(七)truffle使用入门汇总
截止上篇博客,以太坊区块链开发的环境和框架基本上搭建完毕.这一篇博客重点梳理一下基本的流程和操作演示. 前奏 基于前面的安装配置,现在重新梳理一遍,以前博客讲到的就在这里一笔带过. (1)创建一个工作 ...
- 官方文档,才是正途-docker-compose
需要的ingress网络映射,还是host宿主机端口映射: https://docs.docker.com/compose/compose-file/#secrets ================ ...
- [DB2]Linux下安装db2 v9.7
https://www.cnblogs.com/cancer-sun/p/5168728.html
- C# T4使用
最近升级我们的框架到微服务了,而且是dotnetcore 2.0. 然后一个新的框架,最基本的Model和与数据库交互的Repository,我们都是要利用T4自动生成的. 首先这个是代码结构,在这个 ...
- ipython notebook install
1.python install (ubuntut系统默认2.7.x) Github: https://github.com/ipython/ipython 2.sudo apt-get instal ...
- centos7下扩充swap空间
命令:swapon -s #查看系统的swap配置命令 创建步骤: 1. 决定SWAP文件的大小,先指定区块大小:bs,再指定区块数量count,则SWAP文件的大小是:count*bs 在root用 ...
- [BZOJ1069][SCOI2007]最大土地面积(水平扫描法求凸包+旋转卡壳)
题意:在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成. 的多边形面积最大.n<=2000. 先求凸包,再枚举对角线,随着对角线的斜率上升,另外两 ...
- 【BZOJ3167/4824】[Heoi2013]Sao/[Cqoi2017]老C的键盘
[BZOJ3167][Heoi2013]Sao Description WelcometoSAO(StrangeandAbnormalOnline).这是一个VRMMORPG,含有n个关卡.但是,挑战 ...
- 找出能被5或6整除,但是不能被两者同时整除的数 Exercise05_11
/** * @author 冰樱梦 * 时间:2018年下半年 * 题目:找出能被5或6整除,但是不能被两者同时整除的数 * */ public class Exercise05_11 { publi ...
- 使用eclipse调试MR程序
1)点击菜单中的“运行按钮”,然后选择调试配置 2) 3) 这里配置输入路径和输出路径,注意在eclipse上只是在单机模式下Hadoop不会使用HDFS,也不会开启任何Hadoop守护进程,所有程序 ...