zoukankan      html  css  js  c++  java
  • Selenium FF WebDriver运行时开启firebug的2种方式

    上一次我实测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);

    另外一种方法是直接使用Firefox的setPreference

    我们注意到:FF 的extensions.firebug.allPagesActivation设置为ON,firebug会被active

                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);
  • 相关阅读:
    当程序员的那些狗日日子
    程序员常犯的几个错误
    我没有帮你的义务,却有拒绝你的权力
    并发 并行 同步 异步 多线程的区别
    cookie的存取
    sqlserver 处理百万级以上的数据处理与优化
    为什么 jmeter 分布式测试,一定要设置 java.rmi.server.hostname
    详细解析 nginx uri 如何匹配 location 规则
    mysql innodb 从 ibd 文件恢复表数据
    mysql 从 frm 文件恢复 table 表结构的3种方法
  • 原文地址:https://www.cnblogs.com/tobecrazy/p/4040102.html
Copyright © 2011-2022 走看看