Skip to content

Instantly share code, notes, and snippets.

@Tallyb
Created March 29, 2022 11:09
Show Gist options
  • Save Tallyb/773b438f8c51d1981b9ef47a6ce67902 to your computer and use it in GitHub Desktop.
Save Tallyb/773b438f8c51d1981b9ef47a6ce67902 to your computer and use it in GitHub Desktop.
await page.goto('your url')
await page.locator('username').fill('username');
await page.locator('password').fill('123456');
await page.locator('text="Submit").click();
// use this to wait for something to show up that the page has completed loading
await page.locator('some locator').waitFor();
// From your example it is not clear what is the selector logic
// this one will selector all a tags that has attribute resource
// it will return the attribute name on the element
// Tweak the logic to your needs.
const results = await page.$$eval(`a[resource]`, (div) => div.getAttribute('name') );
await fs.writeFileSync('filename', results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment