Firefox Selenium-如何使用控制台、脚本和网络打开firebug

Firefox Selenium-如何使用控制台、脚本和网络打开firebug,firefox,firebug,selenium-rc,Firefox,Firebug,Selenium Rc,我已经设置了一个自定义firefox配置文件,并在selenium RC启动时加载它。该配置文件安装了firebug,当我使用该配置文件手动启动firefox时,firebug处于活动状态。但是,当selenium启动该配置文件时,firebug位于右下角,但未启用。如何确保在启动时启用它?或者,如何启用它或javascript?-我使用的是Java API。方法是使用自定义配置文件打开Firefox。右键单击Firebug图标并为所有网页选择on。关闭Firefox,您就可以开始了!我就是这样

我已经设置了一个自定义firefox配置文件,并在selenium RC启动时加载它。该配置文件安装了firebug,当我使用该配置文件手动启动firefox时,firebug处于活动状态。但是,当selenium启动该配置文件时,firebug位于右下角,但未启用。如何确保在启动时启用它?或者,如何启用它或javascript?-我使用的是Java API。

方法是使用自定义配置文件打开Firefox。右键单击Firebug图标并为所有网页选择on。关闭Firefox,您就可以开始了!我就是这样做的。

如果创建新的Firefox配置文件并将其分配给驱动程序,则需要将新创建的Firefox配置文件的extensions.firebug.allPagesActivation值设置为on

例如,在Ruby中,使用水豚:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension("./firebug-1.10.6.xpi")

profile["extensions.firebug.console.enableSites"] = true
profile["extensions.firebug.net.enableSites"]     = true
profile["extensions.firebug.script.enableSites"]  = true
profile["extensions.firebug.allPagesActivation"]  = "on"

Capybara::Selenium::Driver.new app, :browser => :firefox, :profile => profile

请参阅文档,转到java/c代码中的firefox配置文件位置 从该位置打开firefox。 进行所有必要的设置 这次使用webdriver关闭并重新启动firefox浏览器。
就这样,它解决了你的问题

以下是Python中适合我的内容:

fp = webdriver.FirefoxProfile()

fp.add_extension(extension='firebug-2.0.xpi')
fp.set_preference("extensions.firebug.currentVersion", "2.0") #Avoid startup screen
fp.set_preference("extensions.firebug.console.enableSites", "true")
fp.set_preference("extensions.firebug.net.enableSites", "true")
fp.set_preference("extensions.firebug.script.enableSites", "true")
fp.set_preference("extensions.firebug.allPagesActivation", "on")
driver = webdriver.Firefox(firefox_profile=fp)

它对我不起作用,我在代码中创建并使用了一个新的FirefoxProfile对象,它是否与它有关。
package com.mnas.technology.automation.utility;
import java.io.File;
import java.util.logging.Logger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
/**
* @author manoj.kumar
* @email kumarmanoj.mtech@gmail.com
*/
public class AutomationUtility {
static Logger log = Logger.getLogger(AutomationUtility.class.getName());
public static void main(String[] args) {

// TODO Auto-generated method stub
try {
log.info("Starting Automation...");
log.info("Initializing WebDriver...");

FirefoxProfile ffProfile = new FirefoxProfile();
File firebug = new File(getApplicationPath()+"firebug-2.0.7.xpi");
ffProfile.addExtension(firebug);
ffProfile.setPreference("extensions.firebug.currentVersion", "2.0.7"); //(here you can include the version you currently have)
ffProfile.setPreference("extensions.firebug.showStackTrace", true);
ffProfile.setPreference("extensions.firebug.delayLoad", false);
ffProfile.setPreference("extensions.firebug.showFirstRunPage", false);
ffProfile.setPreference("extensions.firebug.allPagesActivation", "on");
ffProfile.setPreference("extensions.firebug.console.enableSites", true);
ffProfile.setPreference("extensions.firebug.defaultPanelName", "console");
WebDriver driver = new FirefoxDriver(ffProfile);
log.info("WebDriver object activated...");
driver.get("http://www.google.com");
String i = driver.getCurrentUrl();
log.info("CurrentURL===>"+i);
//driver.close();
} catch (Exception e) {
}
}
public static String getApplicationPath()
{
String relPath = System.getProperty("relpath");
return (relPath == null ? System.getProperty("user.dir") :  System.getProperty("user.home") + relPath) + File.separatorChar;
}
}