playwright
playwright copied to clipboard
[BUG] Locators are not being retried on actionability check fail
Context:
- Playwright Version: 1.28.1
- Operating System: Windows
- Node.js version: v16.16.0
- Browser: All
Code Snippet
const {chromium, webkit, firefox} = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.setContent(`
<div style='display: none'>first</div>
<script>
setTimeout(() => {
const div = document.createElement('div')
div.innerText = 'second'
document.body.appendChild(div)
}, 1000)
</script>
`)
await page.locator('div').click()
})();
Describe the bug
- The test page contains a
<div />which is hidden (display: none). It will stay hidden for the remainder of the test. - A second
<div />is appended to the page after a delay of 1s . This<div />is not hidden. - The test case tries to find and click a
<div />element.
The hidden <div /> is not actionable. Therefore, I would expect that Playwright would either click the second <div />, or raise an error that more than one element matches the locator. However, that's not what happens:
- Playwright resolves the locator to the hidden
<div />. - Playwright detects that the div is not actionable.
- Playwright waits until the
<div />becomes actionable. - The test case fails due to a timeout as the
<div />will never become actionable.