Currently diving into the world of e2e testing with Protractor in our Angular application. My current focus is on testing the routing within a specific page. The goal here is to create and trigger a page object that will click on the top row of test data with an id of 7. This action should then activate a routing event that will take me to the intended 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();
}
);
});
});
Following this, I aim to verify if the URL has indeed changed. Despite appearing successful on the automatically opened browser where tests are conducted, the actual test fails:
Expected 'http://localhost:4200/administration/forwardings' to contain 'administration/forwardings/7'.
I have confirmed that the row I am attempting to click is indeed .isPresent()
.
As you can see, I have included several awaits in the code to ensure that the test does not proceed before the routing process is complete. However, this approach does not seem to be entirely effective.
Any suggestions or insights?
______EDIT_______
The issue was not related to the click operation itself. Please refer to my answer for further details.