Skip to content

Commit

Permalink
01_scrape: Use Element.click instead of puppeteer ElementHandle.click
Browse files Browse the repository at this point in the history
Newer puppeteer seems to have trouble clicking on tabs in the
background.
  • Loading branch information
zhuyifei1999 committed Jul 4, 2023
1 parent d5212df commit 8de366c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 01_scrape/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class PageHandler {
}

async handleSpecials(page) {
const softclick = (handle) => handle.evaluate((el) => el.click());

if (this.pageUrl === `${this.parent.origin}`) {
// Puppeteer headless don't fetch favicon
const favicon = await page.$eval('link[rel*=\'icon\']',
Expand All @@ -218,7 +220,7 @@ class PageHandler {
for (const chal of chals) {
// Challenge Tab
this.browseCompleted = new HeartBeat();
await chal.click();
await softclick(chal);
await this.browseCompleted.wait();

const handouts = await page.$$eval('.challenge-files a',
Expand All @@ -230,7 +232,7 @@ class PageHandler {

// Solves Tab
this.browseCompleted = new HeartBeat();
await (await page.$('.challenge-solves')).click();
await softclick(await page.$('.challenge-solves'));
await this.browseCompleted.wait();

await sleep(500);
Expand Down

0 comments on commit 8de366c

Please sign in to comment.