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.

Navigation after click not working regardless of actions I take

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.11
  • Platform / OS version: WSL (openSUSE on Windows)
  • URLs (if applicable): -
  • Node.js version: 10

What steps will reproduce the problem?

So in pure text what I am trying:

  1. Click a button.
  2. Wait until navigation loads. Or simply put - link changes.
  3. Fetch url.
  4. In different incognito browser go to the link and do other actions.

Unfortunately, because I need to fetch the link I can’t use waitForSelector. So I am stuck with navigation and the headache all of that causes. Url is a casual link with dynamically generated ID that I can’t access otherwise.

Code:

await helpers.click(mainUserPage, '#RematchButton');
await mainUserPage.waitForNavigation({waitUntil: "networkidle0"});
 let gameUri = mainUserPage.url();
    await weakerUserPage.goto(gameUri, {
        waitUntil: ['load']
    });

helpers.click:

async function click(page, button) {
   try {
     await page.waitForSelector(button, {visible: true});
     await page.click(button);
   } catch (e) {
     console.log(e);
   }
 }

I tried Promise.all([]) - didn’t help at all. So really I don’t know what to do with that. I am sure navigation causes the headache as without the line button is clicked and navigation is done, just wrong url is fetched.

What is the expected result? Navigation

What happens instead? Blockage

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
thamerlacommented, Dec 15, 2018

Alright another update. After changing navigation lines to:

 async function nativeClick(page, button) {
   await page.evaluate((button) => {
     document.querySelector(button).click();
   }, button);
 }

and using it instead of built-in click method surprisingly the code works 100% and never stops at navigation. Otherwise when there’s a conflict between click redirect & navigation there are ALWAYS problems.

1reaction
thamerlacommented, Dec 13, 2018

Overall puppeteer is a great library but page.click is one huge headache. Even the method itself sometimes works, sometimes it doesn’t… really weird thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How do I handle a click anywhere in the page ...
One possible solution is to handle the mouseup event instead, since event order for clicks is: mousedown; mouseup; click. If you can be...
Read more >
Navigate to a destination - Android Developers
Navigating to a destination is done using a NavController , an object that manages app navigation within a NavHost .
Read more >
Back and Navigate functions in Power Apps - Microsoft Learn
Use the Back and Navigate function to change which screen is displayed. For example, set the OnSelect property of a button to a...
Read more >
How To Fix Google Maps Not Working - Alphr
Google Maps has become a powerful means for navigation. Hence, when the app isn't working, it can cause many issues or even crash...
Read more >
Building Accessible Menu Systems - Smashing Magazine
You should only change this state on click, not on focus. ... Navigation submenus (or "dropdowns" to some) work well with a mouse...
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