Selenium - how to turn on firebug with console, script and net

…衆ロ難τιáo~ 提交于 2020-01-04 07:18:31

问题


I have set up a custom firefox profile and load it when selenium RC starts. The profile has firebug installed, and when I manually launch firefox with that profile, firebug is active. However, when selenium launches that profile, firebug is in the lower right, but it is not enabled. How can I ensure it is enabled at launch? OR, how can I enable it (javascript or ?) - I am using the Java API.


回答1:


The way to do that is to open Firefox using your custom profile. Right-click on the Firebug icon and select "On for All Web Pages". Close Firefox and you should be good to go! That's how I do it.




回答2:


If you create a new Firefox profile and assign it to your driver, you need to set the extensions.firebug.allPagesActivation value of the newly created firefox profile to on.

For example in Ruby, with Capybara:

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

See the documentation for Firebug Preferences




回答3:


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;
}
}



回答4:


Here's what works for me in 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)



回答5:


go to the firefox profile location (which is in your java / c# code) open firefox from that location. make all your required settings close and restart firefox browser this time with your webdriver. that's it, it solves your problem !!



来源:https://stackoverflow.com/questions/4681072/selenium-how-to-turn-on-firebug-with-console-script-and-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!