pg: need elementHandles() instead of all() for internal since it changes
This commit is contained in:
parent
590b01aba2
commit
c4eb1e03ce
1 changed files with 3 additions and 3 deletions
|
|
@ -96,15 +96,15 @@ try {
|
||||||
const games = page.locator('div[data-a-target="offer-list-FGWP_FULL"]');
|
const games = page.locator('div[data-a-target="offer-list-FGWP_FULL"]');
|
||||||
await games.waitFor();
|
await games.waitFor();
|
||||||
console.log('Number of already claimed games (total):', await games.locator('p:has-text("Collected")').count());
|
console.log('Number of already claimed games (total):', await games.locator('p:has-text("Collected")').count());
|
||||||
const internal = await games.locator('[data-a-target="claim-prime-offer-card"]:has-text("Claim")').all();
|
const internal = await games.locator('[data-a-target="claim-prime-offer-card"]:has-text("Claim")').elementHandles(); // can't use .all() here since the list of elements will change after click while we iterate over it
|
||||||
const external = await games.locator('[data-a-target="learn-more-card"]:has(p:text-is("Claim"))').all();
|
const external = await games.locator('[data-a-target="learn-more-card"]:has(p:text-is("Claim"))').all();
|
||||||
console.log('Number of free unclaimed games (Prime Gaming):', internal.length);
|
console.log('Number of free unclaimed games (Prime Gaming):', internal.length);
|
||||||
// claim games in internal store
|
// claim games in internal store
|
||||||
for (const card of internal) {
|
for (const card of internal) {
|
||||||
const title = await card.locator('.item-card-details__body__primary').innerText();
|
const title = await (await card.$('.item-card-details__body__primary')).innerText();
|
||||||
console.log('Current free game:', title);
|
console.log('Current free game:', title);
|
||||||
if (cfg.dryrun) continue;
|
if (cfg.dryrun) continue;
|
||||||
await card.locator('button:has-text("Claim")').click();
|
await (await card.$('button:has-text("Claim")')).click();
|
||||||
db.data[user][title] ||= { title, time: datetime(), store: 'internal' };
|
db.data[user][title] ||= { title, time: datetime(), store: 'internal' };
|
||||||
notify_games.push({ title, status: 'claimed', url: URL_CLAIM });
|
notify_games.push({ title, status: 'claimed', url: URL_CLAIM });
|
||||||
// const img = await (await card.$('img.tw-image')).getAttribute('src');
|
// const img = await (await card.$('img.tw-image')).getAttribute('src');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue