无法使用Netexport和firebug在Selenium Webdriver中生成Har文件

时间:2016-02-22 13:35:54

标签: selenium-webdriver firebug netexport

我正在尝试捕获selenium webdriver中的网络流量,但我没有获得生成的Har文件。

FirefoxProfile profile = new FirefoxProfile();

File firebug = new File(System.getProperty("user.dir")
            + "/CaptureNetTraffic/firebug-2.0.1.xpi");
File netExport = new File(System.getProperty("user.dir")
            + "/CaptureNetTraffic/netExport-0.5.xpi");
try {
    profile.addExtension(firebug);
    profile.addExtension(netExport);
} catch (IOException io) {
    io.printStackTrace();
}

// Set default Firefox preferences
profile.setPreference("app.update.enabled", false);
String domain = "extension.firebug.";

// Set default Firebug preferences
profile.setPreference(domain + "currentVersion", "2.0");
profile.setPreference(domain + "addonBarOpened", true);
profile.setPreference(domain + "console.enableSites", true);
profile.setPreference(domain + "script.enableSites", true);
profile.setPreference(domain + "net.enableSites", true);
profile.setPreference(domain + "allPagesActivation", 1);
profile.setPreference(domain + "addonBarOpened", "on");
profile.setPreference(domain + "onByDefault", true);
profile.setPreference(domain + "defaultPanelName", "net");

// Set default NetExport preferences
profile.setPreference(domain + "netexport.alwaysEnableAutoExport",true);
profile.setPreference(domain + "netexport.Automation", true);
profile.setPreference(domain + "netexport.showPreview", false);
profile.setPreference(domain + "netexport.defaultLogDir", "D:\\myHar");
profile.setPreference(domain + "netexport.autoExportToFile", true);
profile.setPreference(domain + "netexport.sendToConfirmation", false);

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(capabilities); 
   driver.navigate().to("www.google.com");

0 个答案:

没有答案