[Question] Is there way to iterate the Locator elements?
See original GitHub issueHi all,
I would like to iterate the Locator elements while using the ‘of’ operator. For example, if I found several same elements with a page.locator function - is there way to check each of them through the loop iteration:
let arrayOfLocators = page.locator('element);
for (let singleLocator of arrayOfLocators) {
const textOfElement = await singleLocator.innerText();
}
Seems like it is not possible with Locator elements and can be very useful!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Is there a way to iterate over a <li> list in Playwright and click ...
Since https://playwright.dev/docs/api/class-locator#locator-element-handles doesn't have a good example on how to use .elementHandles() .
Read more >how to loop find elements in selenium webdriver - YouTube
In this video we will learn how to iterate find elements in selenium. FindElements will return list of web elements #FindElementsInSelenium ...
Read more >Loop through list of elements and perform a button click
findElement(By.xpath("//div[@class='promotions-text']/parent::div[@class='promotions-block']/following-sibling::div[@class='product-catalog']/ ...
Read more >Locating multiple elements in Selenium Python - GeeksforGeeks
Selenium Python follows different locating strategies for elements. One can locate multiple elements in 7 different ways. Here is a list of ...
Read more >Locators in Selenium: A Detailed Guide - BrowserStack
In this tutorial, we have discussed methods that locate only single elements. One may want to select a group of elements and then...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@DanielStoica85 I managed to solve it with the following code
you could make a generator
now you can iterate over them with a
for await
loop: