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

  1. Selenium webdriver Java firefox 路径设置问题

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

  2. python+selenium webdriver.firefox()方式配置浏览器设置

    webdriver.firefox() 爬虫需求:  (其实是输入参数可获取.zip/pdf 文件,然后点击下载) ——但是firefox浏览器有Bug,点击下载之后会有弹出窗口,需要你点击确定,这怎 ...

  3. Selenium Webdriver firefox 浏览器问题

    Selenium Webdriver 在使用firefox 测试会牵扯到firefox的安装路径的问题 1.默认安装路径在c盘的情况下: WebDriver driver = new FirefoxD ...

  4. python3.x + selenium 3.x 遇到的问题:Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x0045E450>>

    我解决了!!!from selenium import webdriverimport timedr = webdriver.Firefox(executable_path = '/Users/jin ...

  5. selenium webdriver(5)---超时设置

    自动化测试中,等待时间的运用占据了举足轻重的地位,平常我们需要处理很多和时间息息相关的场景,例如: 打开新页面,只要特定元素出现而不用等待页面全部加载完成就对其进行操作 设置等待某元素出现的时间,超时 ...

  6. 【转】Selenium WebDriver + Python 环境

    转自:http://www.myext.cn/webkf/a_11878.html 1. 下载必要工具及安装包 1.1 [Python开发环境] 下载并安装Python 2.7.x版本 下载地址:ht ...

  7. selenium webdriver API

    元素定位 #coding=utf-8 from selenium import webdriver from selenium.webdriver.firefox.firefox_binary imp ...

  8. Selenium在Firefox中踩过的

    本文转至 http://www.51testing.com/html/11/n-3711311.html,作者对webdriver在Firefox中设置profile配置项挺熟的,是用Python实现 ...

  9. Selenium+Headless Firefox

    背景 今天本地调试基于Selenium+PhantomJS的动态爬虫程序顺利结束后,着手部署到服务器上,刚买的热乎的京东云,噼里啪啦一顿安装环境,最后跑的时候报了这么个错误: UserWarning: ...

随机推荐

  1. 本地tomcat访问mysql数据库

    虽然以前经常听人说起过tomcat,但是今天头一次使用tomcat. 1.Tomcat的安装过程: 首先应该从Apache官方网站上下载是用于Windows的.zip压缩包. 下面是相应的下载链接: ...

  2. 【转】iOS开发网络篇—发送json数据给服务器以及多值参数

    原文: http://www.cnblogs.com/wendingding/p/3950132.html 一.发送JSON数据给服务器 发送JSON数据给服务器的步骤: (1)一定要使用POST请求 ...

  3. CGContextRef一点用法

      quartz 是主要的描画接口,支持基于路径的描画.抗锯齿渲染.渐变填充模式.图像.颜色.坐标空间变换.以及PDF 文档的创建.显示.和分析.UIKit 为Quartz 的图像和颜色操作提供了Ob ...

  4. VisualStudio2013内置SQLServer入门

    最近做项目老大要求用到sqlserver,但是这项目的数据库只是本地演示用并不复杂,于是决定试试VisualStudio2013内置的SQLServer.对于这个东西的了解并没有多少,然后项目初学习的 ...

  5. SGU 130.Circle

    答案为Catalan数C(2k, k)/(k+1) #include <stdio.h> using namespace std; int k; int main() { scanf(&q ...

  6. LNMP安装WordPress3.4.2看不到主题解决方法

    喜欢LNMP配置环境的朋友,又是wordpress建立的博客程序,安装之后发现一个问题在网站后台看不到模板主题,重新下载了一款新的主题也查看不了.开始以为是程序的问题,于是我重新下载新版本的WordP ...

  7. eclipse中show whitespace characters显示代码空格,TAB,回车 导致代码乱恶心

    Eclipse中show whitespace characters显示回车.空格符. 取消此功能的第二种方式:

  8. js浏览器键盘事件控制(转自新浪微博)

    js键盘事件全面控制 主要分四个部分第一部分:浏览器的按键事件第二部分:兼容浏览器第三部分:代码实现和优化第四部分:总结 第一部分:浏览器的按键事件 用js实现键盘记录,要关注浏览器的三种按键事件类型 ...

  9. HTML5有语义的内联元素详解

    HTML5有语义的内联元素详解 time标签 time 元素表示一个时间值,比如 5:35 P.M., EST, April 23, 2007.例如: Example Source Code:< ...

  10. Python 异常处理--raise函数用法

    raise语句手工引发一个异常: "raise" [expression ["," expression ["," expression]] ...