How to pass baseUrl from protractor.conf into my test to assert it in tests?
Asked Answered
C

1

23

What I want to do is:

expect(browser.getCurrentUrl()).toEqual(protractor.baseUrl + urls.cookiesPage());

This is what I get:

 - Expected 'https://somewebsite.com/about/cookies/' to equal 'undefined/about/cookies/'.

How to pass baseUrl from config file into my test so I can assert it?

Conlon answered 21/8, 2015 at 14:46 Comment(0)
C
60

5 minutes later, I found an answer... after 2 hours of research:

expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + 'some/url/right/here');

So, this was the answer:

browser.baseUrl
Conlon answered 21/8, 2015 at 14:51 Comment(4)
On my side this assertion throws an error: Argument of type 'string' is not assignable to parameter of type 'Expected<Promise<string>>', not on your side ?Understanding
the only note I can add is that browser.baseUrl returns a different value if you are debugging in vscode. When debugging you don't get a slash on the end, when running 'ng e2e' you do get one. I had to modify my tests accordingly.Solferino
How do you set value for baseurl in config.js ? I did like this but get a compile error . exports.config = { //directConnect: true, framework: 'jasmine', baseUrl='juliemr.github.io/protractor-demo',Aureolin
I can pass it like this but I prefer to mention it in my config,js anyway to achieve it ? Thank you . protractor defaultconfig.js --baseUrl juliemr.github.io/protractor-demoAureolin

© 2022 - 2024 — McMap. All rights reserved.