9

I want to run tests with Firefox/protractor with the cache feature disabled. (Actually, I'm trying to prevent 304 HTTP responses).

There are multiple ways to do this:

  • Disable the cache from the backend-side by droping Etag headers -> I can't modify the backend
  • Drop the Etag header from the frontend-side -> I tried, it did not work
  • Disable the cache from firefox: I just have to set the flag network.http.use-cache to false

Manually it works. I receive only 200 responses and it's great. I want to be able to set this flag through protractor configuration. After some search I found out that I had to create a custom profile and set it in protractor this way (https://code.google.com/p/selenium/wiki/DesiredCapabilities):

capabilities: {
   browserName: 'firefox',
   firefox_profile: 'support/firefox_profile'
 }

The problem is that the firefox profile is not considered. Is it the right option? Do you have a better idea?

Thanks for your help.

EDIT: As someone (suggested

capabilities: {
  prefs: {
    'config.http.use-cache': false
  }
}

It did not work - I checked in about:config, the flag was still enabled. How do you know what options you can pass in the capabilities?

Erem
  • 1,580
  • 3
  • 14
  • 19
  • Sorry @alecxe, updating the topic deleted your response. – Erem Sep 16 '14 at 16:31
  • I've managed to set the firefox preference several weeks ago. I'm trying to find the way I did this. Will provide you with a solution in case I'll figure that out. The solution in the answer haven't worked - had to delete it, sorry. – alecxe Sep 16 '14 at 16:34
  • Would you be okay with a chrome specific solution or firefox is a requirement? – alecxe Sep 16 '14 at 16:39
  • Firefox is a requirement. How would you do it with Chrome? – Erem Sep 16 '14 at 16:54
  • Posted it as an answer. In case of `Firefox`, I'm afraid you are required to use `firefox_profile`. Though, I'm wondering if [`firefox-profile`](https://www.npmjs.org/package/firefox-profile) package can be used with protractor together. – alecxe Sep 16 '14 at 16:59

1 Answers1

11

Here's an example of how to integrate firefox-profile with protractor: https://github.com/juliemr/protractor-demo/tree/master/howtos/setFirefoxProfile

EDIT: For those upgrading to protractor >=1.6, the old way of doing this was broken because 'browser' can no longer return a promise. The demo has been updated.

hankduan
  • 5,994
  • 1
  • 29
  • 43
  • 2
    This is great! Just don't forget to install the modules `q` and `firefox-profile`. Thank you! – Erem Oct 09 '14 at 13:00
  • Note: see [this issue](https://github.com/juliemr/protractor-demo/issues/26) on that same repo for a currently working example. – Mark Lagendijk Feb 18 '19 at 13:03