I know that you can load up either an existing Firefox profile, or create one using Ruby Bindings in the selenium-webdriver gem, as described here:
http://code.google.com/p/selenium/wiki/RubyBindings
And then use add_extension
to add any number of Firefox extensions to the instance, but then what? The window for the extension I'm using does not appear during the test. How do I use the extension?
Is there a way to have the extension be open by default when the driver opens Firefox?
Here is the code I'm using:
#!/usr/bin/env ruby
require "rubygems"
require "selenium-webdriver"
default_profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
default_profile.add_extension("/Users/******/Library/Application Support/Firef\
ox/Profiles/wvon3h99.default/extensions/{9c51bd27-6ed8-4000-a2bf-36cb95c0c947}.\
xpi")
driver = Selenium::WebDriver.for(:firefox, :profile => default_profile)
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
It depends on extension. Usually the extension's behaviour can be to some extent controlled by setting appropriate properties (the ones you can find in about:config) when creating an FF profile. For instance to have Firebug window open by default after FF starts I would include the following line in my code:
default_profile["extensions.firebug.allPagesActivation"] = true
The extensions I use usually have some kind of auto-export feature that automatically sends data to server or saves it on disk. I am afraid there is no way of controlling an extension with WebDriver so not all extensions will be usable in automated tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With