pg: fix internal/external locators, closes #355, waitUntilStable 2s -> 5s

This commit is contained in:
Ralf Vogler 2024-08-02 12:57:37 +02:00
parent d9e91d22c9
commit 8605b70377

View file

@ -101,6 +101,7 @@ try {
let v; let v;
while (true) { while (true) {
const v2 = await f(); const v2 = await f();
console.log('waitUntilStable', v2);
if (v == v2) break; if (v == v2) break;
v = v2; v = v2;
await act(); await act();
@ -109,7 +110,7 @@ try {
const scrollUntilStable = async f => waitUntilStable(f, async () => { const scrollUntilStable = async f => waitUntilStable(f, async () => {
await page.keyboard.press('End'); // scroll to bottom to show all games 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.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"]'); await page.click('button[data-type="Game"]');
@ -118,8 +119,8 @@ try {
await scrollUntilStable(() => games.locator('.item-card__action').count()); await scrollUntilStable(() => games.locator('.item-card__action').count());
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());
// can't use .all() since the list of elements via locator will change after click while we iterate over it // 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 internal = await games.locator('.item-card__action:has(button[data-a-target="FGWPOffer"])').elementHandles();
const external = await games.locator('.item-card__action:has([data-a-target="ExternalOfferClaim"])').all(); const external = await games.locator('.item-card__action:has(a[data-a-target="FGWPOffer"])').all();
// bottom to top: oldest to newest games // bottom to top: oldest to newest games
internal.reverse(); internal.reverse();
external.reverse(); external.reverse();