I'm trying to click on an anchor link within a page that'll open a new tab to export a PDF, but this link lives within a frame inside a frameset like this:
I tried this:
//[login and navigating to the page]
//wait for schedule page
await page.waitForSelector(`frameset`);
//select content frame
const frame = (await page.$("frame[name='link']"));
/*clicking the button after looking for it allow the page to scroll until the button is in frame before clicking it*/
const pdfExport = await frame.$(`a[href='pdf.jsp?clearTree=false']`)
await pdfExport.evaluate(b => b.click()); //error here
await browser.close();
but I get this error:
TypeError: Cannot read properties of null (reading 'evaluate')
at C:\Projects\scrapproject\Main.js:69:25
at processTicksAndRejections (node:internal/process/task_queues:96:5)
it seems that it cannot find my a link button but I cannot figure out how to click it. Can you help me please ?

You are trying to initialize and click on element which is on the main page and not inside the frame. Puppeteer / Playwright have another context for interacting with frames.
Both frameworks have similar context for working with frames.
You can read more about frames context:
Puppeteer: https://pub.dev/documentation/puppeteer/latest/puppeteer/Frame-class.html Playwright: https://playwright.dev/docs/frames
Here is an example snippet of working with frames based on your case:
Puppeteer:
Playwright: