Skip to content
Rill
← All articles

Guides

How to Test a Link That Opens in a New Tab

The Rill Team

Your coding agent adds an Installation guide link to onboarding. You click it and a new tab opens on Documentation. The install command is still a few clicks away.

Start the check where the user clicks. Look at what loads in the new tab, then switch back and check that you can pick up where you left off.

Click from the step the user is on

On Step 2: Connect your project, type demo-workspace into Project name and leave it unsaved. Give Installation guide one plain click.

I tried this on a local Chromium fixture with docs at docs.example.com. The first run redirected to the docs homepage.

CheckExpectedObserved
Click Installation guideA second tab opensA second tab opened
Read the new tab/setup/install shows “Install the CLI”/docs showed “Documentation”
Switch backStep 2 and the unsaved nameStep 2 and the unsaved name

With the redirect corrected, the same click reached Install the CLI at /setup/install. The unsaved project name was still there when I switched back.

Check both tabs with Playwright

Use this in a Playwright Test suite. Swap in your onboarding and destination URLs, the link and heading, and one detail that shows the original tab kept its place. Here it’s the unsaved project name.

import { expect, test } from '@playwright/test';

test('opens the install guide and keeps onboarding in place', async ({ page }) => {
  const onboardingUrl = 'https://app.example.com/onboarding/connect';
  const installUrl = 'https://docs.example.com/setup/install';
  await page.goto(onboardingUrl);

  const step = page.getByRole('region', {
    name: 'Step 2: Connect your project',
    exact: true,
  });
  const projectName = step.getByRole('textbox', { name: 'Project name' });
  await projectName.fill('demo-workspace');

  const [docs] = await Promise.all([
    page.waitForEvent('popup', { timeout: 5000 }),
    step.getByRole('link', { name: 'Installation guide', exact: true }).click(),
  ]);

  const heading = docs.getByRole('heading', { name: 'Install the CLI', exact: true });
  await expect.soft(heading).toBeVisible();
  await expect.soft(docs).toHaveURL(installUrl);

  await page.bringToFront();
  await expect(page).toHaveURL(onboardingUrl);
  await expect(step).toBeVisible();
  await expect(projectName).toHaveValue('demo-workspace');
});

Start listening on the original page before clicking. The destination assertions retry, and a failed soft assertion lets the test reach the original tab before reporting failure. Playwright’s popup guide and assertions reference.

Add the Rill replay to your review

Hosted Browser Check follows supported new-tab links in the tab it records. Use its replay to see the click and landing page. Use Playwright or switch tabs yourself to verify the separate tab and the unsaved state. Rill’s browser task guide.

Rill for Chrome records the tab you select. Local-agent capture follows the page selected at the start, and new tabs can fall outside its video and diagnostics. Chrome recording and local-agent capture.

In the replay, mark the click and the first frame where you can read the heading after redirects. Put those times beside the expected and observed URLs. Mark either tab unverified if you couldn’t inspect it. Watch and share a recording.

Try it on a public staging page with test data. Ask for one click, the final URL, and the heading that appeared. Open Rill Browser Check.