eg: wait for purchaseBtn to have some text, fixes #375

This commit is contained in:
Ralf Vogler 2024-09-01 01:20:45 +02:00
parent fef5b97e3b
commit c8cf7362fa

View file

@ -156,7 +156,7 @@ try {
for (const url of urls) { for (const url of urls) {
if (cfg.time) console.time('claim game'); if (cfg.time) console.time('claim game');
await page.goto(url); // , { waitUntil: 'domcontentloaded' }); await page.goto(url); // , { waitUntil: 'domcontentloaded' });
const purchaseBtn = page.locator('button[data-testid="purchase-cta-button"]').first(); const purchaseBtn = page.locator('button[data-testid="purchase-cta-button"] >> :has-text("e"), :has-text("i")').first(); // when loading, the button text is empty -> need to wait for some text {'get', 'in library', 'requires base game'} -> just wait for e or i to not be too specific; :text-matches("\w+") somehow didn't work - https://github.com/vogler/free-games-claimer/issues/375
await purchaseBtn.waitFor(); await purchaseBtn.waitFor();
const btnText = (await purchaseBtn.innerText()).toLowerCase(); // barrier to block until page is loaded const btnText = (await purchaseBtn.innerText()).toLowerCase(); // barrier to block until page is loaded