Tuesday, 30 May 2017

Modifying / adding request headers to Selenium Firefox profile

I have this code:

  let profile = new firefox.Profile();
  profile.setPreference('modifyheaders.headers.auth_user', 'cdt_admin.gen');
  profile.setPreference('modifyheaders.headers.cdt_app_token', cdtAppToken);

  let opts = new firefox.Options().setProfile(profile);

  let driver = new webdriver.Builder()
  .forBrowser('firefox')
  .setFirefoxOptions(opts)
  .build();

but it's not adding any headers to the request

I believe I need to use a few more lines of code..something like this:

// this is Python I think

fp = webdriver.FirefoxProfile()
path_modify_header = '/Users/foobar/modify_headers-0.7.1.1-fx.xpi'
fp.add_extension(path_modify_header)

How can I do this with Node.js? From what I can tell, it's only possible to modify headers with Firefox..is it really not possible with Google Chrome?

Here are the Selenium JS docs:

https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/profile_exports_Profile.html#addExtension

As the Python example suggests, it's just a string that needs to be passed to profile.addExtension().



via Alexander Mills

No comments:

Post a Comment