Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drive Firebug from Selenium WebDriver

I would like to capture the Net panel output from Firebug while running a test through WebDriver. I was thinking of doing this using NetExport to dump the info to a har file. How can I activate Firebug to do the export while a particular page is displayed using "driver.get()"?

like image 389
shanti Avatar asked Feb 11 '11 02:02

shanti


People also ask

What is firebug how it is used in Selenium?

Firebug is a Mozilla Firefox add-on. This tool helps us in identifying or to be more particular inspecting HTML, CSS and JavaScript elements on a web page. It helps us identify the elements uniquely on a webpage.

What is fire path in Selenium?

What is FirePath. It is an extension to FireBug that adds a development tool to edit, inspect and generate XPath expressions and CSS3 Selectors.

How do I download firebug and FirePath?

Just go to Tools >> Web Developer >> Get More Tools. 2- Search for the FirePath plugin and click on the “Add to Firefox” button. Downloading FirePath Add-on in FireFox.

Which methods navigates to a URL?

Google's Answer: get() is used to navigate particular URL(website) and wait till page load. driver. navigate() is used to navigate to particular URL and does not wait to page load.


1 Answers

You need the Firestarter extension in addition to Firebug and NetExport. Here's how I do it in Ruby:

profile = Selenium::WebDriver::Firefox::Profile.new

profile.add_extension "path/to/firebug.xpi"
profile.add_extension "path/to/fireStarter.xpi"
profile.add_extension "path/to/netExport.xpi")

profile['extensions.firebug.currentVersion']    = "1.7.0a3" # avoid 'first run' tab
profile["extensions.firebug.previousPlacement"] = 1
profile["extensions.firebug.onByDefault"]       = true
profile["extensions.firebug.defaultPanelName"]  = "net"
profile["extensions.firebug.net.enableSites"]   = true

profile["extensions.firebug.netexport.defaultLogDir"]          = output_dir
profile["extensions.firebug.netexport.alwaysEnableAutoExport"] = true

driver = Selenium::WebDriver.for :firefox, :profile => profile

Equivalent APIs are avilable in Java. Make sure the extensions are compatible with each other (and your Firefox version).

If you're using Ruby (or just want to quickly launch a HAR viewer from the command line), check out my HAR gem for an easy way to work with the data later.

like image 196
jarib Avatar answered Nov 08 '22 01:11

jarib