Protractor - Storing a value for later use

341 Views Asked by At

Is there a way to save a value taken from one tests to use it later in another test in protractor. This is a odd case where, i need to read a cookie from the browser only once and have it available for all the spec files i am using in the tests. Reading it in the beforeAll method in each of the spec files is not the solution for me.

For example if i have 5 spec files and when i run the 1st spec file i get the cookie from the browser and the when that cookie information is needed in the following spec files i need to have it available. Is there a way to save this value so it is available for all the spec files? Is this possible?

1

There are 1 best solutions below

0
Delian Mitankin On BEST ANSWER

You can use onPrepare in protractor's config file to execute some code once before all the tests (example).

Keep in mind that you'll have to load a page of your application before being able to use getCookie.