Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -4945,7 +4945,7 @@ async function highlightActiveElement(element) {
}

async function elToString(el, numberOfElements) {
const html = await el.evaluate(node => node.outerHTML)
const html = await el.evaluate(node => node.outerHTML, undefined, { timeout: 100 }).catch(() => '<unavailable>')
return (
html
.replace(/\n/g, '')
Expand Down
33 changes: 33 additions & 0 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,39 @@ describe('Playwright', function () {
.then(res => res.length.should.be.equal(0)))
})

describe('#_locate in debug mode', () => {
it('should not wait for timeout when element is removed before preview', async () => {
await I.amOnPage('/form/field')
await I.executeScript(() => {
const el = document.createElement('div')
el.id = 'removed-element'
document.body.append(el)
})

const locatorProto = Object.getPrototypeOf(page.locator('body'))
const originalAll = locatorProto.all
locatorProto.all = async function () {
const els = await originalAll.call(this)
await page.evaluate(() => document.getElementById('removed-element')?.remove())
return els
}
const debugMode = store.debugMode
store.debugMode = true
page.setDefaultTimeout(10000)

try {
const start = Date.now()
const els = await I._locate('#removed-element')
els.length.should.be.equal(1)
expect(Date.now() - start).to.be.below(1000)
} finally {
locatorProto.all = originalAll
store.debugMode = debugMode
page.setDefaultTimeout(I.options.timeout)
}
})
})

describe('check fields: #seeInField, #seeCheckboxIsChecked, ...', () => {
it('should throw error if field is not empty', () =>
I.amOnPage('/form/empty')
Expand Down
Loading