In the code below I am attempting to use puppeteer to automatically open a list of all of Caeleb Dressel’s times on USA Swimming. Because he doesn’t have any times in 2025, I have to change the selected option in the first dropdown to the one with value="-1"
. I use page.select, but for some reason it doesn’t work, but everything above the await page.waitForSelector("#competitionYearId");
works perfectly fine. I have tried many other methods, but none of them work, and I’m pretty sure page.select should work perfectly fine. How can I fix this?
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://data.usaswimming.org/datahub/usas/individualsearch");
await page.waitForSelector("#firstOrPreferredName", { visible: true });
await page.type("#firstOrPreferredName", "Caeleb");
await page.type("#lastName", "Dressel");
await page.click('button[type="submit"]');
await page.waitForSelector("._ActionButton_8nq2x_59");
await page.evaluate(() => {
const buttons = document.querySelectorAll("._ActionButton_8nq2x_59._ActionIntraPage_8nq2x_159");
if (buttons[0]) {
buttons[0].click();
}
});
await page.waitForSelector("#competitionYearId");
await page.select("#competitionYearId", "-1");
})();