question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to calculate the total number of elements available for a xpath in playwright

See original GitHub issue

Trying to capture multiple elements using below xpath const elements = "xpath=//*[text()='Table']/parent::*//tbody//tr"; getting a total of 50 element for the above xpath in inspect window.

Trying to store all these element using

let value = await this.page.$$(txtBillingRoasterTableRows);
console.log("value length is ",value.length);

but getting value.length as 1. How can I get the expected total of 50?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
pavelfeldmancommented, Dec 2, 2021

You should not wait for the time, you should wait for elements:

await page.locator('tr').first().waitFor();
console.log(await page.locator('tr').count());
1reaction
noxifycommented, Aug 24, 2022

What is output of this code?

the number of rows 😏

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get a collection of elements with playwright?
I have already found the answer. Need to use page.$$(selector) instead of page.$(selector) to grab like document.
Read more >
How To Find Elements For Selenium, Cypress, Playwright
This video explains how to find elements for Selenium WebDriver, Cypress and Playwright using SelectorsHub Chrome Extension and Firefox ...
Read more >
Find Multiple Elements | Playwright - Part 12 - YouTube
Let's learn how to find multiple elements in the playwright.We are also going to explore the "for await" and "map" functions.
Read more >
16 - Comma separated CSS Selectors and Xpath Union
In this video, I have explained how to use Comma separated CSS Selectors and Xpath Union || Playwright with Java.git repo url ...
Read more >
Complete Guide For Using XPath In Selenium With Examples
We will be digging into the steps of locating an element by XPath in Selenium with examples, to help you understand various ways...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found