I have the following element in my code:
<div class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-button" tabindex="0" role="button" aria-disabled="false" id="1"><div class="MuiListItemText-root"><span class="MuiTypography-root MuiListItemText-primary MuiTypography-body1">Arne Nordman (arne@nordman.no)</span></div><span class="MuiTouchRipple-root"></span></div>
This element is a part of a drop-down list that appears after typing into a text field. Unfortunately, when I use the following code, the element can not be identified. It says "DOMException: Failed to execute 'querySelector' on 'Document': '#1' is not a valid selector".
Here is my code:
const puppeteer = require("puppeteer");
async function run() {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto("http://localhost:3000/");
await page.evaluate(() =>
[...document.querySelectorAll("button")].map(
elem => elem.innerText === "Personell & Institutions" && elem.click()
)
);
await page.type("input", "arne");
await page.waitFor(1000);
await page.$eval("#1", el => console.log("elemnet is:", el.innerText));
}
run();
Any help would be truly appreciated!