Selenium FF WebDriver运行时开启firebug的2种方式

发表于:2015-1-13 11:08

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:to be crazy    来源:51Testing软件测试网采编

  上一次我实测FF webdriver 加载firefoxhttp://www.cnblogs.com/tobecrazy/p/3997375.html
  那么问题就来了,既然能加载firebug能否在运行时候直接激活firebug
  效果如下:
  针对这个情况,我们有两种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);
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号