Skip to content

Commit 903e588

Browse files
Copilotkobenguyent
andcommitted
Fix helper tests to expect WebElement instances instead of native elements
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 6f1a4ef commit 903e588

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

test/helper/Playwright_test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,15 +1707,17 @@ describe('Playwright - HAR', () => {
17071707
await I.amOnPage('/form/focus_blur_elements')
17081708

17091709
const webElements = await I.grabWebElements('#button')
1710-
assert.equal(webElements[0], "locator('#button').first()")
1710+
assert.equal(webElements[0].constructor.name, 'WebElement')
1711+
assert.equal(webElements[0].getNativeElement(), "locator('#button').first()")
17111712
assert.isAbove(webElements.length, 0)
17121713
})
17131714

17141715
it('should return a WebElement', async () => {
17151716
await I.amOnPage('/form/focus_blur_elements')
17161717

17171718
const webElement = await I.grabWebElement('#button')
1718-
assert.equal(webElement, "locator('#button').first()")
1719+
assert.equal(webElement.constructor.name, 'WebElement')
1720+
assert.equal(webElement.getNativeElement(), "locator('#button').first()")
17191721
})
17201722
})
17211723
})
@@ -1751,15 +1753,17 @@ describe('using data-testid attribute', () => {
17511753
await I.amOnPage('/')
17521754

17531755
const webElements = await I.grabWebElements({ pw: '[data-testid="welcome"]' })
1754-
assert.equal(webElements[0]._selector, '[data-testid="welcome"] >> nth=0')
1756+
assert.equal(webElements[0].constructor.name, 'WebElement')
1757+
assert.equal(webElements[0].getNativeElement()._selector, '[data-testid="welcome"] >> nth=0')
17551758
assert.equal(webElements.length, 1)
17561759
})
17571760

17581761
it('should find element by h1[data-testid="welcome"]', async () => {
17591762
await I.amOnPage('/')
17601763

17611764
const webElements = await I.grabWebElements('h1[data-testid="welcome"]')
1762-
assert.equal(webElements[0]._selector, 'h1[data-testid="welcome"] >> nth=0')
1765+
assert.equal(webElements[0].constructor.name, 'WebElement')
1766+
assert.equal(webElements[0].getNativeElement()._selector, 'h1[data-testid="welcome"] >> nth=0')
17631767
assert.equal(webElements.length, 1)
17641768
})
17651769
})

test/helper/Puppeteer_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,8 @@ describe('Puppeteer - Trace', () => {
11931193
await I.amOnPage('/form/focus_blur_elements')
11941194

11951195
const webElements = await I.grabWebElements('#button')
1196-
assert.include(webElements[0].constructor.name, 'CdpElementHandle')
1196+
assert.equal(webElements[0].constructor.name, 'WebElement')
1197+
assert.include(webElements[0].getNativeElement().constructor.name, 'CdpElementHandle')
11971198
assert.isAbove(webElements.length, 0)
11981199
})
11991200
})

0 commit comments

Comments
 (0)