Skip to content

[BUG] When clicking on a link navigating away from the website, playwright throws a removeFrameSession failure #1762

Closed

Description

Context:

  • Playwright Version: 0.13.0
  • Operating System: Mac

Code Snippet

it('should work', async () => {
  console.log('goto');
  await page.goto(
    'https://journal.cnishina.dev/2020/04/create-mp4-from-screencast.html');
  await new Promise((resolve) => {
    setTimeout(resolve, 500);
  });
  console.log('click journal');
  await page.click('a[href="https://journal.cnishina.dev/"]');
  console.log('youtube');
  await page.click('a[href="https://youtu.be/dQw4w9WgXcQ"]');
});

Describe the bug

As a person writing a test, if I click on a link that navigates me away from the page, then it should not throw an error. I noticed this when I was clicking the a[href="https://youtu.be/dQw4w9WgXcQ"]. Clicking on this throws an error. I am either looking for documentation explaining targetId and sessionId and why this does not work when this happens (what the workflow should be if we decide to click on a link navigating us away from the main page) or to fix it with:

removeFrameSession(targetId) {
    const frameSession = this._sessions.get(targetId);
    if (!frameSession)
        return;
    // Frame id equals target id.
    const frame = this._page._frameManager.frame(targetId);
    if (frame) {
        this._page._frameManager.removeChildFramesRecursively(frame);
        frameSession.dispose();
        this._sessions.delete(targetId);
    }
}

This just changes the assert(frame); and puts it into a conditional. I've tried out this change and it appears to work but might not be the right fix. Let me know and I can put in a PR this week. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions