Skip to content

Commit

Permalink
pg: fix internal/external locators, closes #355, waitUntilStable 2s -…
Browse files Browse the repository at this point in the history
…> 5s
  • Loading branch information
vogler committed Aug 2, 2024
1 parent d9e91d2 commit 8605b70
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions prime-gaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ try {
let v;
while (true) {
const v2 = await f();
console.log('waitUntilStable', v2);
if (v == v2) break;
v = v2;
await act();
Expand All @@ -109,7 +110,7 @@ try {
const scrollUntilStable = async f => waitUntilStable(f, async () => {
await page.keyboard.press('End'); // scroll to bottom to show all games
await page.waitForLoadState('networkidle'); // wait for all games to be loaded
await page.waitForTimeout(2000); // TODO networkidle wasn't enough to load all already collected games
await page.waitForTimeout(5000); // TODO networkidle wasn't enough to load all already collected games
});

await page.click('button[data-type="Game"]');
Expand All @@ -118,8 +119,8 @@ try {
await scrollUntilStable(() => games.locator('.item-card__action').count());
console.log('Number of already claimed games (total):', await games.locator('p:has-text("Collected")').count());
// can't use .all() since the list of elements via locator will change after click while we iterate over it
const internal = await games.locator('.item-card__action:has([data-a-target="FGWPOffer"])').elementHandles();
const external = await games.locator('.item-card__action:has([data-a-target="ExternalOfferClaim"])').all();
const internal = await games.locator('.item-card__action:has(button[data-a-target="FGWPOffer"])').elementHandles();
const external = await games.locator('.item-card__action:has(a[data-a-target="FGWPOffer"])').all();
// bottom to top: oldest to newest games
internal.reverse();
external.reverse();
Expand Down

0 comments on commit 8605b70

Please sign in to comment.