I am trying to get current url and want to store it as string but .then is always return undefined. Following is the function code:
navigateToLandingPage() {
let EC = protractor.ExpectedConditions;
let currentURL: string;
browser.getCurrentUrl().then ( (url) => {
currentURL = url;
} );
if (currentURL !== 'operator') {
browser.get('localhost:3000/#/operator');
browser.wait(EC.urlContains('/operator'), 10000);
}
I am calling it form spec in this way:
describe('Checking Module', () => {
let page: CalendarModule;
let EC = protractor.ExpectedConditions;
beforeEach(() => {
page = new CalendarModule();
});
it('Clicking on Calendar should redirect to Calendar Module', () => {
page.commonMethodObj.navigateToLandingPage();
let calendarLink = page.getCalendarLink();
calendarLink.click().then(() => {
browser.wait(EC.urlContains('/calendar'), 50000);
expect(browser.getCurrentUrl()).toMatch('/calendar');
});
});
});
I am using following versions of dependencies:
"@angular/core": "2.3.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"protractor": "~4.0.13"