2

I'm in a setup, in which I need to use Firefox Portable 38.7.1 for my Selenium tests (version 2.53.0). Everything works fine, but now I need to configure a proxy.

I configured it in the default profile (it gets saved in ${FF_PORTABLE_PATH}/Data/profile/prefs.js)

user_pref("network.proxy.http", "proxyHost");
user_pref("network.proxy.http_port", proxyPort);
user_pref("network.proxy.share_proxy_settings", true);
user_pref("network.proxy.ssl", "proxyHost");
user_pref("network.proxy.ssl_port", 51854);
user_pref("network.proxy.type", 1);
...

When starting the browser manually, this works fine. However, when triggered by Selenium an anonymous profile is created and used, which doesn't have my proxy settings.

I tried to specify the profile when starting the node.

At first I tried using -Dwebdriver.firefox.profile:

java -jar selenium-server-standalone-2.53.0.jar -role node -Dwebdriver.firefox.profile=default

Then I tried to use the default profile as a template using -firefoxProfileTemplate:

java -jar selenium-server-standalone-2.53.0.jar -role node -firefoxProfileTemplate "${FF_PORTABLE_PATH}/Data" -nodeConfig ...

I also created a new profile (using the ProfilistPortable plugin) and specified it on startup of the node (with the webdriver.firefox.profile-parameter).

In all cases the Selenium node opens up Firefox Portable with a "clean" anonymous profile without my proxy settings.

Can anyone help me how to get this setup working with Firefox Portable? I don't really need separate profiles. As long as I can force Selenium to use a profile, which has the proxy configured, I'm fine.

Here's my nodeConfig:

{
    "capabilities": [
        {
            "browserName": "firefox",
            "version": "38.7.1",
            "firefox_binary": "${FF_PORTABLE_PATH}\\FirefoxPortable.exe",
            "platform": "WINDOWS",
            "maxInstances": 1,
            "seleniumProtocol": "WebDriver"
        }
    ],
    "configuration": {
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 1,
        "port": 5550,
        "host": "ip",
        "register": true,
        "registerCycle": 5000,
        "hubHost": "localhost",
        "hubPort": 4440
    }
}

I use ${FF_PORTABLE_PATH} in the examples above. In reality this (fully qualified) path is hardcoded in all my settings.

Community
  • 1
  • 1
martin
  • 2,150
  • 1
  • 34
  • 48

1 Answers1

0

I had the same issue. Digging into selenium code I was able to find a solution.

FirefoxBinary binary = new FirefoxBinary(new File(portablePath.trim()));
File profile_dir = new File(portablePath.trim().replace("FirefoxPortable.exe", "/Data/profile"));
fp = new FirefoxProfile(profile_dir);
dc.setCapability(FirefoxDriver.PROFILE, fp);
driver  = new FirefoxDriver( binary , fp, dc);
justadev
  • 1,168
  • 1
  • 17
  • 32