Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 959
krosenvold Avatar asked Aug 06 '10 07:08

krosenvold


People also ask

How to run firebug in selenium webdriver?

Press F12. Click on the Firebug icon present in the extreme top-right corner of the Firefox window. Click on Firefox menu bar -> Web Developer -> firebug -> Open Firebug.

What is firebug in selenium?

firebug is a tool to inspect element on page to help you get the CSS locator or xpath which used in selenium script to find element from page. now you can use the devtool to inspect element, like chrome's devtool.


2 Answers

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

like image 171
Sergii Pozharov Avatar answered Oct 08 '22 19:10

Sergii Pozharov


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");

like image 30
Bill Avatar answered Oct 08 '22 20:10

Bill