question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cnishinacommented, Apr 13, 2020
0reactions
cnishinacommented, Apr 13, 2020

Sounds good. I’ll have something in by the end of the day…

Read more comments on GitHub >

github_iconTop Results From Across the Web

click on a link is not working in playwright - Stack Overflow
The root problem seems to be that Playwright is not recognizing the change of the visiblity in the elements after
Read more >
navigation failed because page was closed! - You.com
Error is thrown at the point when I await page.goto(url). Navigation failed because page was closed is the error. Things attempted to no...
Read more >
Back to Basics: Non-Navigating Links for JavaScript Handling
Empty HREF links might be tempting but they are problematic as they basically mean re-navigate the current page. It's like a Refresh operation ......
Read more >
When to use target="_blank" | CSS-Tricks
Anchor links1 may have a target attribute which controls what happens when that link is clicked. One of the possible values of that ......
Read more >
should JavaScript be allowed to change a web link *after* you ...
The next bit of the trick involves using the onclick event to change the href attribute of the link you just clicked. When...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found