Vinay Singh
Vinay Singh

Reputation: 203

accessing baseURL in config file shows undefined value

below is my config file:

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl1: 'https://www.angularjs.org/',
capabilities: {
    'browserName': 'chrome'
},
specs: ['./specs/login.spec.js'],
jasmineNodeOpts: {
    showColors: true,
},
params: {
    baseUrl2: 'https://www.angularjs.org/',
},
onPrepare: function() {
    console.log("URL2 "+browser.params.baseUrl2);
    console.log("URL1 "+browser.baseUrl1);
    browser.driver.manage().window().maximize();
    return browser.get('http://juliemr.github.io/protractor-demo');
    },
};

When I try to access with console.log("URL1 "+browser.baseUrl1); in onPrepare, I am getting undefined value.But Same time when I access console.log("URL2 "+browser.params.baseUrl2); I get the desired value, I am not sure what is the problem here. Here I want to access the baseURL value which is not part of params.

please let me know what mistake I am doing here.

Upvotes: 0

Views: 899

Answers (2)

flaviomeira10
flaviomeira10

Reputation: 586

You should use "baseUrl" variable, with its exact name.

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'https://www.angularjs.org/',
capabilities: {
...

Upvotes: 0

Paqman
Paqman

Reputation: 456

Actually, params are accessible through browser.params.paramName from everywhere (onPrepare, tests files...).

But you can access the baseUrl by using exports.config.baseUrl1 if needed.

Upvotes: 1

Related Questions