Answer the question
In order to leave comments, you need to log in
How to get a list of elements in playwright and work with a specific one?
I have a page yandex.ru
There are menu items with a class "home-link"
How do I check if the 2nd item matches the href?
I tried here in two ways to get a list of elements, but the first one has an error, and the second one is undefined
const { test, expect } = require('@playwright/test')
test('basic test', async ({ page }) => {
await page.goto('https://yandex.ru')
const elements = page.$$('.home-link')
const href = await page.evaluate(() => document.querySelectorAll('.home-link'));
console.log(elements)
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question