This is what I have in protractor.conf.js:

    let localNodeStorage = require('./helpers/localStorageNode');

    exports.config ={onPrepare: async () => {
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));

    await browser.driver.get('https://xpert-integration.gdp3000.com/gdpadminui/login');
    await browser.driver.findElement(by.css('#username')).sendKeys('user');
    await browser.driver.findElement(by.css('#password')).sendKeys('pass');
    await browser.driver.findElement(by.css('.btn-enter')).click();
    localNodeStorage.getValue("AuthenticationToken").then((token) => {
        let authToken= token;

Is there a way to access authToken in my login.ts class? And if so, how?

I tried params{} but it won't work If I just get token from localStorage in login.ts I get authToken undefined.

1 Answer 1


Hi if your params variable is token , then in onprepare call it as

browser.token , instead of browser.parans.token

Another way is to declare a global variable in config file and use it .

In JavaScript it's straight forward as putting

global token , in the top of conf.js and using it as token anywhere else

You can also try out steps listed out in below stack overflow session:


It include approachs like using environment variable ,getting full processedconfig and getting the params property from it , to name a few.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.