Reputation: 147
I've been trying to click on a ceratin tab located just above the headers of a big table. That very tab is named and visible as Pitchers
. Where I'm going wrong?
This is the script I'm trying with:
const puppeteer = require('puppeteer');
(async function main() {
try {
const browser = await puppeteer.launch({headless:false});
const [page] = await browser.pages();
await page.goto('https://www.rotowire.com/baseball/stats.php');
await page.waitForSelector("div[data-name='p']");
const elem = await page.$("div[data-name='p']");
await elem.click();
// await browser.close();
} catch (e) {
console.log('the error: ', e);
}
})();
The error it encounters:
TimeoutError: waiting for selector "div[data-name='p']" failed: timeout 30000ms exceeded
How can I get click on the
Pitchers
tab in that webpage?
Upvotes: 0
Views: 2008
Reputation: 21695
That selector is case-sensitive. This should work:
await page.waitForSelector("div[data-name='P']");
const elem = await page.$("div[data-name='P']");
Using the case-insensitive selector should also work:
await page.waitForSelector("div[data-name='P' i]");
const elem = await page.$("div[data-name='P' i]");
Upvotes: 2