【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 ...
随机推荐
- UNITY UI字体模糊的原因
根本原因:像素少. 解决办法:字体的 font size将像素设置大些,然后用scale来缩放大小
- SYN Flood 防范
简介: SYN Flood 是 DoS( 拒绝服务攻击 )与 DDoS( 分布式拒绝服务攻击 )的方式之一,这是一种利用 TCP 协议缺陷,发送大量伪造 TCP 连接请求,从而使得服务器资源耗尽( C ...
- web前端整套面试题(三)--网易的面试题
题型分析: 一.选择题部分(30分) 元素出栈可能性 排序方法的优缺点 HTTP请求方法 关系型数据库种类 多线程(进程与线程共享) 计算机网络协议 linux指令 JQuery实现方法 二.编程题( ...
- redis 面试题2
使用过Redis分布式锁么,它是什么回事? 先拿setnx来争抢锁,抢到之后,再用expire给锁加一个过期时间防止锁忘记了释放. 这时候对方会告诉你说你回答得不错,然后接着问如果在setnx之后执行 ...
- Jenkins持续集成构建
配置Sonar.Jenkins进行持续审查 http://go2live.cn/archives/38261.html Jenkins iOS 项目持续集成 http://go2live.cn/arc ...
- Django常见出错解决方案汇总-乾颐堂
一.模板类型错误: 错误原因:在models中漏掉了return: class UserProfile(models.Model): """ 功能说明: 扩 ...
- query使用
1.row_array():返回查询结果中的第一条数据 include APP_PATH . "../mysql.class.php";$db = new mysql();$sql ...
- SetDns.bat 2014-03-28 20:00:19
此BAT文件,可以帮助便捷切换dns设置,Win7系统需使用管理员身份运行. @echo off echo 设置为GoogleDNS(1)/dhcp(2)/OpenDNS(3) set /p sel= ...
- modifiers标量调节器插件的定义和使用
在插件目录plugins里新建文件 modifier.插件名.php文件(如 modifier.插件名.php)例:function smarty_modifier_test($utime, $for ...
- tomcat启动报错:java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.45\webapps\activiti-explorer does not exist or is not a readable directory
java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.45\webapps\erp does not exist ...