0

I am trying to change the state of my application with clicking on a link, but it doesn't work. The console always says /home.

  it('should change the route', () => {
    expect(browser.getCurrentUrl().toString().endsWith("/home")).toBeTruthy();

    element.all(by.css("li")).last().click();

    browser.waitForAngular().then(() => {
      browser.getCurrentUrl().then(text => {
        console.log(text);
      });
      expect(browser.getCurrentUrl().toString().endsWith("/customer")).toBeTruthy();
    });
  });

What did I miss? The documentation of protractor isn't very helpful in context of state navigation.

CSchulz
  • 10,882
  • 11
  • 60
  • 114
  • Have you tried to [wait for URL to change](http://stackoverflow.com/questions/34358542/protractor-generic-wait-for-url-to-change)? – alecxe Oct 05 '16 at 19:21
  • Btw, you can make the assertion a little bit more readable with `toEndWith()` from [`jasmine-matchers`](https://github.com/JamieMason/Jasmine-Matchers). – alecxe Oct 05 '16 at 19:23
  • Thanks, but doesn't change anything. I have to refactor it because it is a promise. – CSchulz Oct 05 '16 at 19:29
  • So, in other words, it is not a timing issue and it does not matter how long you wait? Is it just the click not doing what you expect it to do? – alecxe Oct 05 '16 at 19:30
  • Seems like that the click doesn't change anything. – CSchulz Oct 05 '16 at 19:39
  • Are you sure you are targeting the desired element and not clicking a different element? – alecxe Oct 05 '16 at 19:42

0 Answers0