0
votes

I am using Protractor typescript for automation of angular application. When i run the using "npm run e2e" then i have observed that angular is always listening on https://localhost:4200.

I Tried to declare baseUrl in Protractor.conf.js as param as below -

params:
    {
    baseUrl: 'http://www.angular.io'}
    ,

I am passing that baseUrl to navigate method in e2e-spec.ts as below -

 page.navigateTo(browser.params.baseUrl);

But i don't want to pass Url each time in it block to the navigate() method. So i want baseUrl should be set once and reflected or used by all spec-ts file as base url. Like when i run the application using "npm run e2e" it automatically launches https://localhost:4200

Can you please help me , how to change url at one place e.g. in protraactor.conf.js and it should automatically used by navigate() in spec.ts.

Thanks for you help...

1
Have you tried adding baseUrl: 'http://www.angular.io' in protractor.conf.js as a top level property? (e.g. on the same level as specs, capabilities, onPrepare etc.) - Protozoid
Basically i want to know how it always launch localhost:4200. I read it is due to default behavior i.e. angular always listening on 4200. - simond
Yes i have tried but it still launching localhost:4200, When i call -page.navigateTo('/'); then expectation is it should navigate to baseUrl which i have provided - simond
this command worked for me protractor --basurl=sites.net but dont why it is not working when i set base url and say npm run e2e - simond
Please show your package.jsonn in your question - yong

1 Answers

1
votes

Declare the baseUrl in config file as below,

exports.config = {
framework: 'custom',
//frameworkPath: protractorCucumberFramework,
frameworkPath: require.resolve('protractor-cucumber-framework'),

seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'your application url',

//Browser Configurations
capabilities: {
    'browserName': 'chrome',
    chromeOptions: {
        // Chrome is controlled by automated software : disable"
        'args': ['disable-infobars=true'],
    }
},

And in Spec file, Call the baseUrl as mentioned below,

 browser.get("");

It Should work.