javascript - how test separate environmental name with protractor conf js? -
[
the above pic run protractor conf.js particular environmental name stored in json file
how test particular environmental url in protractor test case?
first method - have pass parameters using params
variable in command line. update conf.js
file include parameter called baseurl
, other url variables shown below -
params: { baseurl: "http://default_url" //provide default url used }
later pass value in command prompt. here's how -
protractor conf.js --params.baseurl 'http://www.google.com'
wherever have code url in spec's, use following code -
browser.get(browser.params.baseurl);
second method - if @ don't want pass url params
object everytime, can store them in conf.js or specs file , call them. here's example -
your conf.js
file -
params: { baseurl: "" }, onprepare: function(){ switch(browser.params.baseurl){ case 'firsturl': browser.get("http://firsturl.com"); //replace firsturl actual url break; case 'secondurl': browser.get("http://www.secondurl.com"); break; default: browser.get("http://www.defaulturl.com"); } }
now pass url's want use through command line -
protractor conf.js --params.baseurl 'firsturl' //to first url protractor conf.js //to open default url
third method - if @ have problem of running test suite many spec's, in case above second method wouldn't work. need use browser.get()
in each of test spec files, in such cases use following method -
update conf.js file -
params: { baseurl: "", url: "" }, onprepare: function(){ switch(browser.params.baseurl){ case 'firsturl': browser.params.url = "http://firsturl.com"; //replace firsturl actual url break; case 'secondurl': browser.params.url = "http://www.secondurl.com"; break; default: browser.params.url = "http://www.defaulturl.com"; } }
your command line commands -
protractor conf.js --params.baseurl 'firsturl' //to first url protractor conf.js //to open default url
your test spec files need include browser.get()
command. here's how -
browser.get(browser.params.url);
hope helps.
Comments
Post a Comment