Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: waitForSelector doesn't consider elements above current viewport as "visible" #9232

Closed
pasieronen opened this issue Nov 8, 2022 · 0 comments · Fixed by #9249
Closed
Assignees
Labels

Comments

@pasieronen
Copy link

Bug description

#8954 changed waitForSelector "visible" flag behavior to consider only elements inside the current viewport as visible. This was reverted in #9087, but it looks like the revert wasn't complete. Apparently elements below the current viewport are now considered "visible", but not elements above (or left) of the current viewport.

Simple script to reproduce (works with 17.1.3, fails with 19.2.2):

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({headless: false});
  const page = await browser.newPage();
  await page.setViewport({width: 800, height: 600});
  await page.setContent(`
    <html><body>
    <button id="button1">Button 1</button>
    <div id="content" style="height: 2000px;"></div>
    <button id="button2">Button 2</button>
    </body></html>
  `);
  await page.waitForSelector('#button1', {visible: true});
  await page.waitForSelector('#button2', {visible: true});
  console.log('ok, both buttons are visible');
  await page.evaluate(() => window.button2.scrollIntoView());
  await page.waitForSelector('#button1', {visible: true});
  console.log('ok, button1 still visible (although outside viewport)');
  await browser.close();
})();

Puppeteer version

19.2.2

Node.js version

16.18.0

npm version

8.19.2

What operating system are you seeing the problem on?

macOS

Configuration file

No response

Relevant log output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants