firefox浏览器不需要下载驱动,原生支持,以下是代码运行环境,firefox启动封装在方法startFirefox()中

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver; public class browser<Webdirver> {
public static void main(String[] args) {
WebDriver driver = startFF();
driver.get("http://www.baidu.com");
driver.quit();
}
public static WebDriver startFF(){
    .......
    return WebDriver ;
  }    //firefox不同的启动方式修改该方法即可
}

1、firefox安装在默认路径下:


public static WebDriver startFF(){
  WebDriver driver = new FirefoxDriver();//启动默认路径下的firefox
  return driver;
}

2、firefox未安装在默认路径下:

public static WebDriver startFF(){
  System.setProperty("webdriver.firefox.bin","D:/**/**/firefox.exe");//指定firefox的安装路径
  WebDriver driver = new FirefoxDriver();//启动指定路径下的firefox
  return driver;
}

3、启动firefox时设置配置

public static WebDriver startFF(){
FirefoxProfile profile = new FirefoxProfile();
//设置默认下载路径
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "D:\\"); 
  
  WebDriver driver = new FirefoxDriver(profile);//启动指定路径下的firefox
  return driver;
}

4、启动firefox时启动插件

【Selenium专题】WebDriver启动firefox浏览器的更多相关文章

  1. Webdriver启动Firefox浏览器后,页面显示空白

    在使用pycharm码代码时编译总是出错,后来验证发现浏览器启动后出现问题.白白耗了我2个小时.我把我的解决方案写出来,希望对大家有帮助. 1.现象:起初安装的时候总是能正常运行,有一天突然发现Web ...

  2. selenium webdriver 启动三大浏览器Firefox,Chrome,IE

    selenium webdriver 启动三大浏览器Firefox,Chrome,IE 1.安装selenium 在联网的情况下,在Windows命令行(cmd)输入pip install selen ...

  3. selenium+python启动Firefox浏览器失败问题和点击登陆按钮无效问题

    问题1:使用python+selenium编写脚本调用Firefox时报错:

  4. 7.解决在python中用selenium启动FireFox浏览器启动不了的方法

    首次在利用python中的selenium启动FireFox浏览器时可能碰到如下问题 当输入如下代码时: from selenium import webdriver brower=webdriver ...

  5. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法

    通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...

  6. selenium webdriver启动IE浏览器失败的解决办法

    通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...

  7. Java&Selenium根据实参启动相应浏览器

    Java&Selenium根据实参启动相应浏览器 /** * 定义函数initBrowser * @param browser:字符串参数chrome/ie/xx * @return 并返回驱 ...

  8. 【Selenium专题】WebDriver启动Chrome浏览器(一)

    selenium操作chrome浏览器需要有ChromeDriver驱动来协助.一.什么是ChromeDriver?ChromeDriver是Chromium team开发维护的,它是实现WebDri ...

  9. Selenium加载Chrome/Firefox浏览器配置文件

    Selenium启动浏览器时,默认是打开一个新用户,不会加载原有的配置以及插件.但有些时候我们可能需要加载默认配置. 一.Chrome浏览器 1.在Chrome浏览器的地址栏输入:chrome://v ...

随机推荐

  1. Camera & Render

    1.void Render(); Description Render the camera manually. This will render the camera. It will use th ...

  2. Texture Combiner

    [Texture Combiner] After the basic vertex lighting has been calculated, textures are applied. In Sha ...

  3. AddComponentMenu

    [AddComponentMenu] The AddComponentMenu attribute allows you to place a script anywhere in the " ...

  4. CMDB-客户端

    配置文件的设置 大体思路: 1,通过开始文件将用户配置信息的文件放置到环境变量中. 2,在lib文件中的config文件中,从环境变量中获取到用户的配置,通过importlib模块导入用户配置文件,通 ...

  5. Python 生成MYSQL inser语句

    背景: 一般来说,navicat生成的insert已经够用了 如果说一张表有2,30个字段,每个字段还得一一对上,其实是很难的.所以抽空写了个小程序.用它完全不用担心字段对不上了.因为没有时间,需要手 ...

  6. NSArray & NSDictionary

    一.NSArray 1.1 简单创建方法由难到简 NSArray *arr = [[NSArray alloc] init]; NSArray *arr = [NSArray arrayWithObj ...

  7. 572. Subtree of Another Tree 大树里包括小树

    [抄题]: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure ...

  8. DevCloud for CloudStack Development

    Apache CloudStack development is not an easy task, for the simplest of deployments one requires a se ...

  9. [C++] Lvalue and Rvalue Reference

    Lvalue and Rvalue Reference int a = 10;// a is in stack int& ra = a; // 左值引用 int* && pa ...

  10. LWIP网络接口管理

    LAN8720+RJ45+MAC(STM32F4自带的)构成了网络接口层.