Rayrun
← Back to Discord Forum

playwright doesnt redirect to another page when a redirect button is clicked

while registering a form clicking on next button does not redirect to a new page

This thread is trying to answer question "How do I click a button to redirect to a new page in Playwright?"

16 replies

clicked on it but does not navigate to a new page

how do i click a button to redirect to a new page

you can use this for ref:

async openTargetBlankLink(locator: Locator, url: RegExp): Promise<void> {
    const [newPage] = await Promise.all([this.page.context().waitForEvent('page'), locator.click()]);
    await newPage.waitForLoadState('load');
    await expect(newPage, 'Page is not opened').toHaveURL(url);
    await newPage.close();
  }```

i have it in POM and it was working earlier

after filling the form, then clicking on next button it takes like 3-4 seconds before it navigates to a new page @dmrock 'registratistion completed ' 'message pops up before redirecting to new page

<button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium w-full py-3 font-semibold rounded-md shadow-sm text-md px-14 text-mffu-gray-100 bg-gradient-to-r from-mffu-cream-100 to-mffu-blue-100 hover:from-mffu-cream-100 hover:to-mffu-cream-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mffu-cream-100 css-1uyurgq" tabindex="0" type="submit">Next<span class="MuiTouchRipple-root css-w0pj6f"></span></button>

here's the locator

i clicked on a button to redirect to a new page but it failed

Still on it

playwright doesnt redirect to another page when a redirect button is clicked

@deepgadhia

@here

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.