Hello,
I am working on the automation of tests with ruby using watir-webdriver
and selenium environment. I am refactoring code that was designed for
older firefox versions. But it seems that on the latest version (v34),
the plugins are disabled by default, which impacts my tests.
I figured out that I have to set the created borwser preference
‘plugin.default.state’ to the value “2” in order to bypass this. But I
don’t managed to do it properly.
For other browsers like chrome we are using capabilities to set
properties as we need, but I didn’t find if I can do the same for
firefox : I think I have to set up a dedicated profile and here is where
I am stuck.
Here is my code before refactoring (extract):
require ‘watir-webdriver’
(…)
def open_browser
$problem_browser = false
case $browsername
when ‘firefox’
caps = Selenium::WebDriver::Remote::Capabilities.firefox
(…)
if $problem_browser == false
caps[“platform”] = $os_without_version
$b = Watir::Browser.new(
:remote,
:url => “http://my_url/wd/hub”,
:desired_capabilities => caps
)
end
end
(…)
and now, I have modified it to this :
require ‘watir-webdriver’
(…)
def open_browser
$problem_browser = false
case $browsername
when ‘firefox’
caps = Selenium::WebDriver::Remote::Capabilities.firefox
aFirefoxprofile = Selenium::WebDriver::Firefox::Profile.new
aFirefoxProfile[‘plugin.default.state’] = 2
caps =
Selenium::WebDriver::Remote::Capabilities.firefox(“firefox_profile” =>
aFirefoxProfile)
(…)
if $problem_browser == false
caps[“platform”] = $os_without_version
$b = Watir::Browser.new(
:remote,
:url => “http://my_url/wd/hub”,
:desired_capabilities => caps
)
end
end
(…)
But it seems that the “new” method does not create the profile I want.
the assignment Selenium::WebDriver::Remote::Capabilities.firefox is
working without requiring the selenium gem, but not the
Selenium::WebDriver::Firefox::Profile.new ? Am I doing it wrong ?
Sorry for my ignorance and thank you by advance for your attention.