Skip to content

Instantly share code, notes, and snippets.

@asvinours
Last active October 16, 2022 20:54
Show Gist options
  • Save asvinours/89a2990e4148a60909b24ae7b9f02dfe to your computer and use it in GitHub Desktop.
Save asvinours/89a2990e4148a60909b24ae7b9f02dfe to your computer and use it in GitHub Desktop.
Unsuscribe from AWS marketing emails using Playwright
const { chromium } = require('playwright');
if (process.argv.length !== 3) {
console.error('Expected exactly one argument!');
process.exit(1);
}
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://pages.awscloud.com/communication-preferences');
await Promise.all([
page.click('#Unsubscribe_bttn'),
page.waitForSelector('#AWS-Preference-Center', { timeout: 5000 }),
page.waitForLoadState('networkidle'),
]);
await page.locator('#Email').fill(process.argv[2]);
await Promise.all([
page.waitForSelector('#LblUnsubscribed', { timeout: 5000 }),
page.click('#LblUnsubscribed'),
]);
await Promise.all([
page.waitForNavigation(),
page.click('text=Submit'),
page.waitForSelector('text=Your changes are updated and you will no longer receive promotional email communications from AWS'),
page.waitForLoadState('networkidle'),
]);
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment