Playwright - verify list of elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should return multiple books when partial title is given', async () => { | |
await page.fill('#searchBar', 'test') | |
await page.waitForSelector('li.ui-screen-hidden', { state: 'attached' }) | |
const expectedBooks = [ | |
'Test Automation in the Real World', | |
'Experiences of Test Automation', | |
'Agile Testing', | |
'How Google Tests Software', | |
'Java For Testers'] | |
const visibleBooksSelector = 'li:not(.ui-screen-hidden)' | |
const visibleBooks = await page.$$(visibleBooksSelector) | |
assert.equal(visibleBooks.length, expectedBooks.length) | |
expectedBooks.forEach(book => async () => { | |
assert.equal(await page.innerText(visibleBooksSelector + ' >> h2'), book) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment