0

I write a test for a link with Protractor(using Pattern Page Object), but it always gave an error. So I decide to see what was going on and I write this one:

test.spec.js

it('It should redirect to Google.de', function(){
    var logo = angularPage.logo3;
    angularPage.clickLink(logo);           
    browser.getCurrentUrl().then(function (url) {
        console.log('---> url:'+url);
    });
});

login.page.js

this.navigate = function(ptor) {
    browser.get(browser.baseUrl);
    ptor = protractor.getInstance();
    ptor.waitForAngular();
}

this.clickLink = function(link){
    link.click();
    var ptor;
    this.navigate(ptor);
}

And what I got was the link didn't redirect me to another web page. I think is weird because the link actually works when I click on it. Anyone know what that can be happening?

Thanks.

Community
  • 1
  • 1
Cremix_hellven
  • 895
  • 2
  • 7
  • 13

1 Answers1

0

My problem was that when you try to get current URL you can get it with two ways:

Supports AngularJS

var logo = angularPage.logoH3;
angularPage.clickLink(logo);
browser.getCurrentUrl().then(function (url) {
    console.log('---> URL: '+url);
});

No Supports AngularJS

var logo = angularPage.logoH3;
angularPage.clickLink(logo);
browser.driver.getCurrentUrl().then(function (url) {
    console.log('---> URL: '+url);
});

So login.page.js stays finally like this

login.page.js

this.clickLink = function(link){
    link.click();
}

Thanks for your helping and your time ;)

Cremix_hellven
  • 895
  • 2
  • 7
  • 13