问题: 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 路径设置问题的更多相关文章

  1. Selenium Webdriver java 积累一

    Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriv ...

  2. [selenium webdriver Java]常用api

    1. 获取元素文本 WebElement类的getText()方法返回元素的innerText属性.所以元素里如果有子节点一样也会被返回出来.如下所示 public class GetText { @ ...

  3. Selenium webdriver firefox 路径设置问题

    问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...

  4. Selenium webdriver Java 高级应用

    对于这一段还蛮有感慨的,只想说,代码还是需要自己去敲的. 1. 改变用户代理 import org.junit.AfterClass; import org.junit.BeforeClass; im ...

  5. Selenium WebDriver java 简单实例

    开发环境 JDK 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse: 下载地址:http ...

  6. Selenium webdriver Java 操作IE浏览器

    V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...

  7. Selenium webdriver Java 开始

    最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirv ...

  8. [selenium webdriver Java]隐式的等待同步

    Selenium WebDriver提供了隐式等待来同步测试.当使用了隐式等待执行测试的时候,如果WebDriver没有在DOM中找到元素,将继续等待,超出设定时间后,抛出找不到元素异常 即,当元素没 ...

  9. Java 学习笔记 (二) Selenium WebDriver Java 弹出框

    下面这段实例实现了以下功能: 1. profile使用用户本地电脑上的 (selenium 3有问题.因为selenium 3把profile复制到一个temp文件夹里,但并不复制回去.所以每次打开仍 ...

随机推荐

  1. Servlet中使用 Last-Modified、Expires和Cache-Control

    long now = System.currentTimeMillis(); long expires = System.currentTimeMillis() + (1000 * 60 * minu ...

  2. Interface与abstract类的区别

    含有abstract修饰符的class即为抽象类,abstract 类不能创建的实例对象.含有abstract方法的类必须定义为abstract class,abstract class类中的方法不必 ...

  3. Codeforces 810 C. Do you want a date?

    C. Do you want a date? time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  4. CSU 1330 字符识别? 【找规律】

    你的任务是写一个程序进行字符识别.别担心,你只需要识别1, 2, 3,如下: .*.  ***  *** .*.  ..*  ..* .*.  ***  *** .*.  *..  ..* .*.  ...

  5. CodeForces 669C

    链接:http://codeforces.com/problemset/problem/669/C http://www.cnblogs.com/Ash-ly/p/5443155.html 题意: 给 ...

  6. RabbitMQ (四) 工作队列之公平分发

    上篇文章讲的轮询分发 : 1个队列,无论多少个消费者,无论消费者处理消息的耗时长短,大家消费的数量都一样. 而公平分发,又叫 : 能者多劳,顾名思义,处理得越快,消费得越多. 生产者 public c ...

  7. centos 7下查找大文件、大目录和常见文件查找操作

    根据园子 潇湘隐者的文章 <Linux如何查找大文件或目录总结>结合实际运维需要整理出常用命令 目标文件和目录查找主要使用 find 命令 结合 xargs (给命令传递参数的一个过滤器, ...

  8. telnet执行过程及验证远程服务器是否打开

    telnet执行过程: 工作原理: 当你用Telnet登录进入远程计算机系统时,你事实上启动了两个程序,一个 叫Telnet客户程序,它运行在你的本地机上:另一个叫Telnet服务器程序,它运 行在你 ...

  9. @requestBody注解的使用(下)

    提示: 建议一定要看后面的@RequestBody的核心逻辑源码以及六个重要结论!本文前半部分的内容都是一些基本知识常          识,可选择性跳过. 说明: @RequestBody主要用来接 ...

  10. Java高级架构师(一)第15节:带查询的分页、修改和删除页面

    @RequestMapping(value="toList",method=RequestMethod.GET) public String toList(@ModelAttrib ...