Selenium FF WebDriver运行时开启firebug的2种方式
2014-10-21 13:17
357 查看
上一次我实测FF webdriver 加载firefox/article/4969963.html
那么问题就来了,既然能加载firebug能否在运行时候直接激活firebug
效果如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202009/04/59b65c7afa348dd63d114c143aecdb61.jpg)
针对这个情况,我们有两种solutions
方法1:使用firebug的快捷键F12激活firebug
不过这需要使用Actions class 的sendKeys method,使用sendKeys方法别忘了添加perform() 方法 否则不执行的
另外一种方法是直接使用Firefox的setPreference
我们注意到:FF 的extensions.firebug.allPagesActivation设置为ON,firebug会被active
![](https://oscdn.geek-share.com/Uploads/Images/Content/202009/04/2e7128acf9a89a85c0feddb6a07f02d6.jpg)
那么问题就来了,既然能加载firebug能否在运行时候直接激活firebug
效果如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202009/04/59b65c7afa348dd63d114c143aecdb61.jpg)
针对这个情况,我们有两种solutions
方法1:使用firebug的快捷键F12激活firebug
不过这需要使用Actions class 的sendKeys method,使用sendKeys方法别忘了添加perform() 方法 否则不执行的
File file=new File("C:\\webdriver\\firebug-2.0.4-fx.xpi");//设置Firebug路径 FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 2); profile.setPreference("network.proxy.autoconfig_url", "http://proxy.successfactors.com:8083"); //自动代理配置 try { //add firebug profile.addExtension(file); profile.setPreference("extensions.firebug.currentVersion", "2.0.4");//设置firebug 版本 } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } WebDriver driver = new FirefoxDriver(profile); driver.get("http://www.dbyl.cn"); Actions actions=new Actions(driver); //F12 is a short cut of active firebug //do not forget perform actions.sendKeys(Keys.F12).perform(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
另外一种方法是直接使用Firefox的setPreference
我们注意到:FF 的extensions.firebug.allPagesActivation设置为ON,firebug会被active
![](https://oscdn.geek-share.com/Uploads/Images/Content/202009/04/2e7128acf9a89a85c0feddb6a07f02d6.jpg)
File file=new File("C:\\webdriver\\firebug-2.0.4-fx.xpi");//设置Firebug路径 FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 2); profile.setPreference("network.proxy.autoconfig_url", "http://proxy.successfactors.com:8083"); //自动代理配置 try { //add firebug profile.addExtension(file); profile.setPreference("extensions.firebug.currentVersion", "2.0.4");//设置firebug 版本 //active firebug extensions profile.setPreference("extensions.firebug.allPagesActivation", "on"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } WebDriver driver = new FirefoxDriver(profile); driver.get("http://www.dbyl.cn"); Actions actions=new Actions(driver); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
相关文章推荐
- Selenium2.0介绍——WebDriver两种驱动浏览器的方式.
- 转:Selenium2.0介绍——WebDriver两种驱动浏览器的方式
- Selenium Webdriver元素定位的八种常用方式(转载)
- Selenium FF WebDriver 遍历所有链接(另类爬虫)
- Ubuntu linaro(Lubuntu ARM) (Cubieboard CC-A80) Chromium 运行Selenium Webdriver
- Selenium Webdriver元素定位的方式
- selenium webdriver 学习总结-浏览器启动方式(二)
- Selenium Webdriver元素定位的八种常用方式
- Selenium学习笔记之006:webdriver的八种定位方式
- selenium webdriver 学习总结-浏览器启动方式
- Selenium Webdriver元素定位的八种常用方式
- Selenium Webdriver元素定位的八种常用方式
- Selenium的RC方式编写的测试脚本部分迁移到WebDriver方式混用的简单示例
- selenium-webdriver用例批量运行和测试套件使用 ------之我见
- Selenium FF WebDriver 遍历所有链接(另类爬虫)
- selenium WebDriver 清空input的方式
- selenium(webdirver)--在Firefox webdriver实例中添加Firebug and FirePath插件
- 去哪儿网输入框三种输入方式(selenium webdriver 干货)
- Selenium Webdriver元素定位的八种常用方式