krosenvold
krosenvold

Reputation: 77121

How do I run Firebug within Selenium WebDriver (Selenium 2)?

What's the best way to activate Firebug in Firefox when running Selenium 2?

Edit: Ok, I realize "best" is open to interpretation, but the profile-based solution really used to be a pain with selenium 1.0. So any alternative is considered better until proved worse ;)

Upvotes: 26

Views: 23951

Answers (9)

Vittal Manikonda
Vittal Manikonda

Reputation: 46

I have observed that the firebug is adding to browser and it is disabled by default and not enabled ,when i add firebug to firefox at runtime by using webdriver. So to make it enable we may need to add the below line to profile.

profile.setEnableNativeEvents(true);

Upvotes: 0

Rohit Naik
Rohit Naik

Reputation: 19

If none of the above option works. Then try this.

  • 1) Open terminal and type below command (close all existing firefox sessions first)

firefox -p

  • 2) This will open an option to create a new Firefox profile.
  • 3) Create a profile lets say "SELENIUM".
  • 4) Once the firefox is open straight away install firebug or any other plugins extension that you want. once done close the window.
  • 5) Now load this new profile via selenium , use below java statements.

    ProfilesIni profile = new ProfilesIni();

    FirefoxProfile ffprofile = profile.getProfile("SELENIUM");

    WebDriver driver = new FirefoxDriver(ffprofile);

  • 6) Done. Enjoy.

Upvotes: 0

rethab
rethab

Reputation: 8403

I found a profiles.ini in ~/.mozialla/firefox/. In there was a profile named default, which I specified a like the following and then firefox was opened in test just like I opened it regularly (with all plugins etc).

java -jar selenium.jar -Dwebdriver.firefox.profile=default

Upvotes: 0

Srichandar.Karpuram
Srichandar.Karpuram

Reputation: 29

modify your firefox location to something like C:\Users\user-name\AppData\Roaming\Mozilla\Firefox\Profiles\sgmqi7hy.default launch your firefox from selenium / webdriver make all your required settings close and restart firefox browser from selenium / webdriver that's it, it solves your problem !!

Upvotes: 0

Sergii Pozharov
Sergii Pozharov

Reputation: 17828

You can create your profile in code and dynamically add required add-ons. Let's assume that you saved Firebug XPI into the C:\FF_Profile folder as firebug.xpi (go to Firebug download page, right-click on the "Add To Firefox" and save as C:\FF_Profile\firebug.xpi).

In code:

   final String firebugPath = "C:\\FF_Profile\\firebug.xpi";
   FirefoxProfile profile = new FirefoxProfile();       
   profile.addExtension(new File(firebugPath));
   // Add more if needed
   WebDriver driver = new FirefoxDriver(profile);

This is described in WebDriver FAQ

Upvotes: 47

Ripon Al Wasim
Ripon Al Wasim

Reputation: 37746

Assuming that, Firebug is installed. Your objective is to run Firebug. Firebug can be run/execute by pressing F12 key. So Firebug can be run by following command of Selenium WebDriver with Java:

Actions action = new Actions(driver);
action.sendKeys(Keys.F12).build().perform();

Upvotes: -2

bukzor
bukzor

Reputation: 38462

Apparently the way the firefox-profile options are consumed has changed in Selenium WebDriver.

The old commandline (Selenium RC):

java -jar selenium-2.28.0.jar -firefoxProfileTemplate ~/.mozilla/firefox/3knu5vz0.selenium

Updated for WebDriver: (note that it wants the profile name rather than the directory)

java -jar selenium-2.28.0.jar -Dwebdriver.firefox.profile=selenium

Upvotes: 1

Aaron Fi
Aaron Fi

Reputation: 10396

Just reference your profile by name. Example in Ruby:

@driver = Selenium::WebDriver.for :firefox, :profile => "default"

Then, load Firefox normally, and add your desired extensions. They will now show up in your Selenium test runs.

Upvotes: 1

Bill
Bill

Reputation: 429

Do you mean having firebug installed in the browser instance that webdriver launches? If so, you can pass an extension when you instantiate the driver, but the eaisest way is to create a firefox profile with firebug installed and then use the following code before you instantiate the driver:

System.setProperty("webdriver.firefox.profile", "NAME_OF_FIREFOX_PROFILE_WITH_FIREBUG");

Upvotes: 10

Related Questions