-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script from playwright codegen + iframe fix + notes
- Loading branch information
0 parents
commit e5ce791
Showing
5 changed files
with
4,035 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
auth.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# epicgames-claimer | ||
|
||
Tried https://github.com/Revadike/epicgames-freebies-claimer, but it does not work anymore since epicgames introduced hcaptcha: | ||
https://github.com/Revadike/epicgames-freebies-claimer/issues/172 | ||
|
||
Played around with puppeteer before, now trying newer https://playwright.dev which is pretty similar. | ||
Playwright Inspector and `codegen` to generate scripts are nice, but failed to generate the right code for iframe. | ||
Works up to button 'I Agree', then it shows an hcaptcha. | ||
|
||
- https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra | ||
- https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth | ||
- https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-recaptcha | ||
- `playwright-extra@next`: https://github.com/berstend/puppeteer-extra/pull/303#issuecomment-775277480 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { existsSync } from 'fs'; | ||
|
||
if (!existsSync('auth.json')) { | ||
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.'); | ||
} | ||
test.use({ | ||
storageState: 'auth.json', | ||
viewport: { width: 1280, height: 1280 }, | ||
}); | ||
|
||
test('claim game', async ({ page }) => { | ||
await page.goto('https://www.epicgames.com/store/en-US/free-games'); | ||
await expect(page.locator('a[role="button"]:has-text("Sign In")')).toHaveCount(0); | ||
await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug | ||
await page.click('[data-testid="offer-card-image-landscape"]'); | ||
// TODO check if already claimed | ||
await page.click('[data-testid="purchase-cta-button"]'); | ||
await page.click('button:has-text("Continue")'); | ||
// it then creates an iframe for the rest | ||
// await page.frame({ url: /.*store\/purchase.*/ }).click('button:has-text("Place Order")'); // not found because it does not wait for iframe | ||
const iframe = page.frameLocator('.webPurchaseContainer iframe') | ||
await iframe.locator('button:has-text("Place Order")').click(); | ||
await iframe.locator('button:has-text("I Agree")').click(); | ||
await page.pause(); | ||
}); |
Oops, something went wrong.