【Selenium专题】WebDriver启动firefox浏览器
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浏览器的更多相关文章
- Webdriver启动Firefox浏览器后,页面显示空白
在使用pycharm码代码时编译总是出错,后来验证发现浏览器启动后出现问题.白白耗了我2个小时.我把我的解决方案写出来,希望对大家有帮助. 1.现象:起初安装的时候总是能正常运行,有一天突然发现Web ...
- selenium webdriver 启动三大浏览器Firefox,Chrome,IE
selenium webdriver 启动三大浏览器Firefox,Chrome,IE 1.安装selenium 在联网的情况下,在Windows命令行(cmd)输入pip install selen ...
- selenium+python启动Firefox浏览器失败问题和点击登陆按钮无效问题
问题1:使用python+selenium编写脚本调用Firefox时报错:
- 7.解决在python中用selenium启动FireFox浏览器启动不了的方法
首次在利用python中的selenium启动FireFox浏览器时可能碰到如下问题 当输入如下代码时: from selenium import webdriver brower=webdriver ...
- selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...
- selenium webdriver启动IE浏览器失败的解决办法
通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...
- Java&Selenium根据实参启动相应浏览器
Java&Selenium根据实参启动相应浏览器 /** * 定义函数initBrowser * @param browser:字符串参数chrome/ie/xx * @return 并返回驱 ...
- 【Selenium专题】WebDriver启动Chrome浏览器(一)
selenium操作chrome浏览器需要有ChromeDriver驱动来协助.一.什么是ChromeDriver?ChromeDriver是Chromium team开发维护的,它是实现WebDri ...
- Selenium加载Chrome/Firefox浏览器配置文件
Selenium启动浏览器时,默认是打开一个新用户,不会加载原有的配置以及插件.但有些时候我们可能需要加载默认配置. 一.Chrome浏览器 1.在Chrome浏览器的地址栏输入:chrome://v ...
随机推荐
- Centos 安装旧版php5.2
# yum remove php-* # cd /root/ && mkdir new_php && cd new_php # wget -r http://yum.m ...
- MySQL数据库篇之初识数据库
主要知识点: 一.数据库概述 二.mysql安装与基本管理 1️⃣ 数据库概述 1.什么是数据(Data)? 描述事物的符号记录称为数据,描述事物的符号既可以是数字,也可以是文字.图片,图像.声音. ...
- Makefile里面打印信息
Makefile的规则相对来说还是比较复杂的,上手不容易,没有系统研究过,往往搞不清楚状况.如果掌握了基本的调试手段,那对我们写出正确的Makefile会非常有帮助.而在Makefile中,最重要的调 ...
- HttpServletResponse返回页面弹窗
下载方法: @RequestMapping(value = "/download.htm") public void downLoadFile(String id,HttpServ ...
- css实现类似heigth:100%的方法
1. 效果 2. 代码 2.1. Html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...
- JS中的函数声明和函数表达式的区别,即function(){}和var function(){},以及变量提升、作用域和作用域链
一.前言 Uncaught TypeError: ... is not a function function max(){}表示函数声明,可以放在代码的任何位置,也可以在任何地方成功调用: var ...
- cacti监控mssql 2005运行资源情况
概述:SQL Server2000\2005\2008本身不支持snmp,使用cacti监控mssql,必须通过php连接mssql来获取SQL 2005性能计算器的值. 操作步骤: 1.php连接m ...
- Openssl req命令
一.简介 req指令用来创建和处理PKCS#10格式的证书 二.语法 openssl req [-inform PEM|DER] [-outform PEM|DER] [-in filename] [ ...
- 创建一个实例&创建一个线程。。
using System; using System.Threading; namespace WorkerThread02 { class ThreadTest { bool done; stati ...
- tp5循环+判断