I'm testing the navigation on our website using expect(page.url()).toContain('/nav');
.
When walking through the code I can clearly see that we hit that url string after the click.
I've tried putting my code into and outside of a promise granting the same error:
Expected substring: "/nav"
Received string: "https://website.com/about"
283 | page.waitForNavigation();
284 | await page.hover('nav >> text=Nav');
285 | await page.click('nav >> text=Nav');
286 | console.log(page.url());
> 287 | expect(page.url()).toContain('/nav');
| ^
288 |
289 | page.click('text=Next Nav')
290 | expect(page.url()).toContain('/nextNav');
The link itself is a simple <a href="/nav" class="list__item__link" data-v-0df6efc8>Nav</a>
.
The console log shows https://website.com/about
.
Here's a snippet related to the comments:
////##OURSTORY##////
page.hover('nav >> text=Our Story');
page.waitForNavigation();
await page.click('nav >> text=About');
expect(page.url()).toContain('story');
//await page.pause();
await page.hover('nav >> text=Our Story');
await page.hover('nav >> text=360° Wellness');
await page.click('nav >> text=360° Wellness');
console.log(page.url());
await page.waitForNavigation();
expect(page.url()).toContain('/360-wellness');