Merge pull request #21603 from cdeutsch/puppeteer-fix

puppeteer fixes
This commit is contained in:
Benjamin Lichtman
2017-11-21 10:30:45 -08:00
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@@ -725,7 +725,7 @@ export interface FrameBase {
): Promise<void>;
waitForSelector(
selector: string,
options?: { visible: boolean; timeout: number }
options?: { visible?: boolean; hidden?: boolean; timeout?: number }
): Promise<void>;
}
@@ -1148,6 +1148,10 @@ export interface LaunchOptions {
args?: string[];
/** Close chrome process on Ctrl-C. Defaults to true. */
handleSIGINT?: boolean;
/** Close chrome process on SIGTERM. Defaults to true. */
handleSIGTERM?: boolean;
/** Close chrome process on SIGHUP. Defaults to true. */
handleSIGHUP?: boolean;
/**
* Maximum time in milliseconds to wait for the Chrome instance to start.
* Defaults to 30000 (30 seconds). Pass 0 to disable timeout.

View File

@@ -118,7 +118,7 @@ puppeteer.launch().then(async browser => {
let currentURL: string;
page
.waitForSelector("img")
.waitForSelector("img", { visible: true })
.then(() => console.log("First URL with image: " + currentURL));
for (currentURL of [
"https://example.com",
@@ -160,7 +160,10 @@ puppeteer.launch().then(async browser => {
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
]
],
handleSIGINT: true,
handleSIGHUP: true,
handleSIGTERM: true,
});
const page = await browser.newPage();
await page.goto("https://example.com");