Skip to content

Instantly share code, notes, and snippets.

Created Sep 11, 2020
What would you like to do?
Playwright - verify list of elements
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