I am starting to learn e2e test with Protractor in our Angular app. Now I am trying to test the routing in one of the pages. All this should do is to spin up a page object and click on the top row of our test data with the id 7. This (click)-Event triggers should trigger a routing event which takes me to the desired page.
forwarding.e2e-spec.ts
let detailsPage: ForwardingDetailsPo;
beforeAll(async () => {
page = new ForwardingPagePo();
await page.navigateTo();
detailsPage = new ForwardingDetailsPo();
table = await page.getForwardingTablePo();
await table.getTable().getRow('7').click();
});
afterEach(async () => {
await detailsPage.navigateTo('7');
});
it('should navigate to details', async (done) => {
browser.getCurrentUrl().then(url => {
expect(url).toContain('administration/forwardings/7');
done();
}
);
});
});
After that I try to check if the url has changed. The automatically opened browser, on which the tests are run seems to execute the task perfectly, yet the test fails:
Expected 'http://localhost:4200/administration/forwardings' to contain 'administration/forwardings/7'.
I already checked that the row I try to click .isPresent()
.
As you can see I tryed to litter the code with awaits to avoid, that the test runs before the routing completes, but that does not seem to work perfectly.
Hints anyone?
______EDIT_______
The solution had nothing to do with the click itself, see my answer for details.