Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Setting user agent on Firefox and using seleniumAddress at the same time does not work #2678

Closed
fbarbat opened this issue Nov 5, 2015 · 3 comments

Comments

@fbarbat
Copy link

fbarbat commented Nov 5, 2015

Hi,

I want to set a specific user agent using Firefox. If I use directConnect on protractor.conf.js, it works:

var firefox = require('selenium-webdriver/firefox');
var firefoxProfile = new firefox.Profile();
firefoxProfile.setPreference("general.useragent.override", 'monitoring1152936086');

exports.config = {
    directConnect: true,

    capabilities: {
        'browserName': 'firefox',
        'firefox_profile': firefoxProfile
    },
    ...
}

However, if I use seleniumAddress instead of directConnect it does not work. For example:

var firefox = require('selenium-webdriver/firefox');
var firefoxProfile = new firefox.Profile();
firefoxProfile.setPreference("general.useragent.override", 'monitoring1152936086');

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',

    capabilities: {
        'browserName': 'firefox',
        'firefox_profile': firefoxProfile
    },
    ...
}

As a side note, I cannot use chrome since I am trying to use Firefox as a workaround to the not so stable combination of protractor and selenium-docker with chrome (SeleniumHQ/docker-selenium#87).

Any ideas? Thanks!

@fbarbat fbarbat changed the title Setting user agent on Firefox using seleniumAddress does not work Setting user agent on Firefox and using seleniumAddress at the same time does not work Nov 5, 2015
@NickTomlin
Copy link
Contributor

Hi there!

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

I haven't personally encountered this issue; my gut is that it's to do with selenium. Let's get to the bottom of it on one of the mediums above. Thanks!

@fbarbat
Copy link
Author

fbarbat commented Nov 5, 2015

Ok, I just find it strange that one way works and the other not. I have checked protractor source and it looks like different code is used to get a web driver (if I had it right):

  • on directConnect it uses (protractor/lib/driverProviders/direct.js):
driver = new firefox.Driver(this.config_.capabilities);
  • seleniumAddress it uses (protractor/lib/driverProviders/driverProvider.js):
 var newDriver = new webdriver.Builder().
      usingServer(this.config_.seleniumAddress).
      withCapabilities(this.config_.capabilities).
      build();

But let's see on StackOverflow. I posted it here: http://stackoverflow.com/questions/33545039/setting-user-agent-on-firefox-with-protractor-and-using-seleniumaddress-does-not

@sjelin
Copy link
Contributor

sjelin commented Nov 5, 2015

I answered the SO question to the best of my understanding. Thanks for reposting there!

@sjelin sjelin closed this as completed Nov 5, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants