【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 ...
随机推荐
- angularjs 出现 “Possibly unhandled rejection: cancel ”错误
Try adding this to your config. I had a similar is once and this workaround did the trick. app.confi ...
- 运动函数封装(js)
// 运动函数 function starMove(obj,json,fnEnd){ clearInterval(obj.timer); obj.timer = setInterval(functi ...
- css常用属性总结之 id和class的区别,使用类还是ID?
前面两篇文章我们分别谈到了class和id的相关知识和如何使用,但是在实际项目中,我们该如何抉择,class还是id? 先回顾下两者的区别吧! 1.id具有唯一性,class具有普遍性,所以一个页面同 ...
- JSP的原理、JSP的执行过程
Jsp的本质是servlet, 通过response的printWriter返回,response的getOutputStream只能调用一次,返回流就不能返回页面刷新. JSP起源 在很多动态网页中 ...
- Nginx源码完全注释(7)ngx_palloc.h/ngx_palloc.c
ngx_palloc.h /* * NGX_MAX_ALLOC_FROM_POOL should be (ngx_pagesize - 1), i.e. 4095 on x86. * On Windo ...
- CSS的编写规范
一.前言 如上图,页面在渲染和画图时,耗时还是比较多的,这就对我们的编写要求愈加严格. 我们有很多方法来减少上图所示的页面加载耗时的,比如 但是更多的还是在于平时的编写规范,我们需要了解浏览器,让他更 ...
- java-tip-Collections.synchronized系列生成的容器
这个系列的容器,和Vector或者HashTable之流的差不多, 区别是: Vector和HashTable是在关键方法上加synchronized关键字 而 Collections.synchro ...
- 利用SHELL脚本修改当前环境变量
转自http://www.chinaunix.net/old_jh/7/21485.html 1.背景 ---- 在日常的工作中,为了设置一大批环境变量,我们通常编辑了一个shell程序,包含了多个的 ...
- c++对象模型是什么,对象的内存布局和结构问题
在c++发明的初期对于c++对象模型的争论从来没有停止过直到标准委员会通过了最终的c++对象模型这件事情才变得尘埃落定.C++对象模型可能是最不需要去解释的,但是又是不得不去说的因为c++的入门最先接 ...
- Openssl rsa命令
一.简介 Rsa命令用于处理RSA密钥.格式转换和打印信息 二.语法 openssl rsa [-inform PEM|NET|DER] [-outform PEM|NET|DER] [-in fil ...