Created
July 10, 2018 12:57
-
-
Save bambooom/87f94e89ca0a9805934edcd4d8953f96 to your computer and use it in GitHub Desktop.
handle multiple pages
This file contains hidden or 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
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ headless: false }); | |
const page = await browser.newPage(); | |
await page.goto('https://test-navlang-demo-vvkpjvrhym.now.sh'); | |
await page.setViewport({ width: 1380, height: 900 }); | |
await page.waitFor(1000); | |
const page2 = await browser.newPage(); | |
await page2.goto('https://www.google.com/'); | |
await page.bringToFront(); // use this to activates Tab | |
// use elementHandle.type | |
const selectElem = await page.$('select[name="choose1"]'); | |
await selectElem.type('Value 2'); | |
// use page.select | |
await page.select('select[name="choose2"]', 'val3'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
any body is able to interact with elements in second page