Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing base url from command line in protractor

i am trying to test my angularjs app using protractor. my conf.js looks like this

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

capabilities: {
    'browserName': 'chrome'
},
specs: ['HomePageCtrl_spec.js'],
chromeOnly: true,
jasmineNodeOpts: {
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true
},
onPrepare: function() {
    browser.manage().window().setSize(1600, 1000);
},
params : {
    url : 'test'
}};

and i am runnig this command on command prompt

protractor Conf.js --params.url='https://XXXXX/YYY'

in my spec file, in beforeEach function i am able to get the passed url (console.log((browser.params.url)) is coming correctly), but when i do browser.get(browser.params.url).. it is not working

anyone has idea why this is failing?

like image 371
rrahul963 Avatar asked Dec 25 '22 13:12

rrahul963


1 Answers

Protractor provides it by default. You just have to declare the correct variable.

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

capabilities: {
    'browserName': 'chrome'
},
specs: ['HomePageCtrl_spec.js'],
chromeOnly: true,
jasmineNodeOpts: {
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true
},
onPrepare: function() {
    browser.manage().window().setSize(1600, 1000);
},
  baseUrl: 'test'
};

and then, you run the tests:

protractor Conf.js --baseUrl="https://XXXXX/YYY"

To use this url within your tests:

browser.get(browser.baseUrl)
like image 71
flaviomeira10 Avatar answered Dec 27 '22 04:12

flaviomeira10