Hello currently i’m working with playwright and wanted to catch nested elements
and put the values in array.
Currently trying to do something like this in my code :
await test.step('Extract table data from HTML', async () => {
const targetContainer = await page.locator('.new-item-container[style="width: 4190px; transform: translate(0px, 0px);"]');
await targetContainer.waitFor();
const tableData = await targetContainer.evaluate(container => {
const tables = container.querySelectorAll('table');
const data = [];
tables.forEach(table => {
const rows = table.querySelectorAll('tbody > tr');
const rowData = [];
rows.forEach(row => {
const cells = row.querySelectorAll('td');
const cellData = [];
cells.forEach(cell => {
cellData.push(cell.innerText.trim());
});
rowData.push(cellData);
});
data.push(rowData);
});
```
and this is my html code that i'm trying to catch in playwright, wanted to go through all of the items in the tables - this tables have tbody with tr and a lot of tds inside
“`
Tried to do this directly in the browser and i’m catching them without a problem, but still struggling to make it work in playwright.