Skip to content

Instantly share code, notes, and snippets.

@pavelfeldman
Created February 2, 2021 18:25
Show Gist options
  • Save pavelfeldman/290c238e3e025eaebcd8f3816b7169ba to your computer and use it in GitHub Desktop.
Save pavelfeldman/290c238e3e025eaebcd8f3816b7169ba to your computer and use it in GitHub Desktop.
const { chromium } = require('.');
(async () => {
const browser = await chromium.launch({
headless: false,
});
const context = await browser.newContext({
// _traceDir: '.trace'
recordVideo: {
dir: '.video',
// size: { width: 800, height: 600 }
}
});
// Open new page
const page = await context.newPage();
// Go to https://github.com/microsoft
await page.goto('https://github.com/microsoft');
await page.waitForTimeout('1000');
// Click input[aria-label="Find a repository…"]
await page.click('input[aria-label="Find a repository…"]');
// Fill input[aria-label="Find a repository…"]
await Promise.all([
page.waitForNavigation(/*{ url: 'https://github.com/microsoft?q=playwright&type=&language=' }*/),
page.type('input[aria-label="Find a repository…"]', 'playwright', { delay: 500 })
]);
// Click //a[normalize-space(.)='playwright']
await page.click('//a[normalize-space(.)=\'playwright\']');
// assert.equal(page.url(), 'https://github.com/microsoft/playwright');
await page.waitForTimeout('2000');
// Click text="Issues"
await Promise.all([
page.waitForNavigation(/*{ url: 'https://github.com/microsoft/playwright/issues' }*/),
page.click('text="Issues"')
]);
await page.waitForTimeout('2000');
// Click text="triaging"
await Promise.all([
page.waitForNavigation(/*{ url: 'https://github.com/microsoft/playwright/issues?q=is:issue+is:open+label:triaging' }*/),
page.click('text="triaging"')
]);
await page.waitForTimeout('2000');
// ---------------------
console.time('VIDEO SAVE');
await context.close();
console.timeEnd('VIDEO SAVE');
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment