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文件夹里,但并不复制回去.所以每次打开仍 ...
随机推荐
- jQuery获取标签中的元素
获取双标签之间的内容 在JavaScript中,获取双标签之间的内容是这样的: <!DOCTYPE html> <html lang="en"> <h ...
- hdu 3304(直线与线段相交)
Segments Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12042 Accepted: 3808 Descrip ...
- python2.7.12自带pip吗?
是的,在安装python2.7.12时自带pip安装包,可以在python安装包Scripts下面可以看到.
- 查询oracle数据库中当前数据库所有表的名称
http://www.cnblogs.com/hyq0002013/p/5948419.html select t.table_name from user_tables t;
- int 与 String 与 char 之间的互相转换
int 转 String: //方式一: int i1 = 888; String s1 = Integer.toString(i1); //方式二: int i2 = 888; String s2 ...
- Vue CLI3 关闭热替换后出现的warning
用vue cli3做项目的时候如果开启了typescript的严格模式,在dev server热替换的时候往往就会打出一大堆warning,严重的影响了编译效率.官方并没有提供关闭warning的ap ...
- POJ 3087 Shuffle'm Up【模拟/map/string】
Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14471 Accepted: 6633 Descrip ...
- 奶牛与农夫John与oj
当蒟蒻的我悲惨的发现oj出现大量的奶牛与农夫时,觉得早晚usaco要占领oj,于是绝望的开始记录农夫与奶牛的题目……. 一道usaco月赛的题…在oj用作练习二维数组,虽然数据的大量字符确实很让人不爽 ...
- (转) C#解惑:HashSet<T>类
HashSet<T>是一个相对“冷门”的类型,平时在项目中用得不多,但是在特定的业务中可以大用. 先来了解下HashSet<T>类,主要被设计用来存储集合,做高性能集运算,例如 ...
- 【kd-tree】bzoj4066 简单题
同p1176. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ...