npm login -> npm run login
This commit is contained in:
parent
0394dc3f94
commit
81b04f6f2f
3 changed files with 4 additions and 4 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Setup: `npm install && npx playwright install` (downloads {chromium, firefox, webkit} (742 MB) to cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries))).
|
Setup: `npm install && npx playwright install` (downloads {chromium, firefox, webkit} (742 MB) to cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries))).
|
||||||
|
|
||||||
Run `npm login` which opens a browser where you can login. When closing the browser, it writes a file `auth.json` containing cookies that should keep you logged in for some time (`expires` in a month?).
|
Use `npm run login` which opens a browser where you can login. When closing the browser, it writes a file `auth.json` containing cookies that should keep you logged in for some time (`expires` in a month?).
|
||||||
|
|
||||||
Then use `npm start` to run Chrome in headless mode to claim the current free game.
|
Then use `npm start` to run Chrome in headless mode to claim the current free game.
|
||||||
If something goes wrong, use `PWDEBUG=1 npm start` to [inspect](https://playwright.dev/docs/inspector).
|
If something goes wrong, use `PWDEBUG=1 npm start` to [inspect](https://playwright.dev/docs/inspector).
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; // only npm dep needed for this
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
|
|
||||||
if (!existsSync('auth.json')) {
|
if (!existsSync('auth.json')) {
|
||||||
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.');
|
console.error('Missing auth.json! Use `npm run login` to login and create this file by closing the opened browser.');
|
||||||
}
|
}
|
||||||
test.use({
|
test.use({
|
||||||
storageState: 'auth.json',
|
storageState: 'auth.json',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//@ts-check
|
//@ts-check
|
||||||
const { existsSync } = require('fs');
|
const { existsSync } = require('fs');
|
||||||
if (!existsSync('auth.json')) {
|
if (!existsSync('auth.json')) {
|
||||||
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.');
|
console.error('Missing auth.json! Use `npm run login` to login and create this file by closing the opened browser.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ const newStealthContext = async (browser, contextOptions = {}) => {
|
||||||
await page.goto('https://www.epicgames.com/store/en-US/free-games');
|
await page.goto('https://www.epicgames.com/store/en-US/free-games');
|
||||||
await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug
|
await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug
|
||||||
if (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) {
|
if (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) {
|
||||||
console.error('Not signed in anymore. Run `npm login` to login again.');
|
console.error('Not signed in anymore. Use `npm run login` to login again.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
// click on banner to go to current free game. TODO what if there are multiple games?
|
// click on banner to go to current free game. TODO what if there are multiple games?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue