添加到配置文件后,在WebDriver中禁用了Firebug

时间:2013-01-17 22:43:40

标签: java firefox selenium-webdriver

我似乎无法弄清楚当我尝试在Firefox WebDriver中点击它时,我的Firebug扩展程序显示其禁用的原因。

这是我的代码的样子,我从SO answer得到了一些代码:

private final String firefoxExtPath = "/Users/[NAME]/Library/Application Support/Firefox/Profiles/4izeq9he.default/extensions/";
private final String firebugPath = firefoxExtPath + "firebug@software.joehewitt.com.xpi";
private final String firepathPath = firefoxExtPath + "FireXPath@pierre.tholence.com.xpi";

private WebDriver dummy;
private WebDriver driver;
...

@BeforeClass
public void addFirefoxExt() {
    // Add extensions to FirefoxDriver
    FirefoxProfile profile = new FirefoxProfile();
    try {
        profile.addExtension(new File(firebugPath));
        profile.addExtension(new File(firepathPath));

        profile.setPreference("extensions.firebug.currentVersion", "1.11.1");
        profile.setPreference("extensions.firebug.onByDefault", true);
        profile.setPreference("extensions.firebug.defaultPanelName", "net");
        profile.setPreference("extensions.firebug.net.enableSites", true);
    } catch (IOException e) {
        e.printStackTrace();
    }

    dummy = new FirefoxDriver(profile);
    driver = new FirefoxDriver(profile);
}

@BeforeClass
public void setup() {
    dummy.get(BASE_URL);
    dummy.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    ...
}

1 个答案:

答案 0 :(得分:0)

这就是我从https://code.google.com/p/selenium/wiki/FirefoxDriver得到的。他们运作良好。

使用萤火虫运行

Download the firebug xpi file from mozilla and start the profile as follows:

File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); 
// Avoid startup screen

WebDriver driver = new FirefoxDriver(firefoxProfile);