[puppeteer] Fix return signatures that contain null (#21424)

This commit is contained in:
Sean Tan
2017-11-13 06:58:14 -08:00
committed by Andy
parent f8e25077c3
commit 938afa59cc
2 changed files with 12 additions and 12 deletions
+7 -7
View File
@@ -202,7 +202,7 @@ export interface BoundingBox {
}
export interface ElementHandle extends JSHandle {
boundingBox(): BoundingBox;
boundingBox(): BoundingBox | null;
click(options?: ClickOptions): Promise<void>;
focus(): Promise<void>;
hover(): Promise<void>;
@@ -227,7 +227,7 @@ export interface ExecutionContext {
}
export interface JSHandle {
asElement(): ElementHandle;
asElement(): ElementHandle | null;
dispose(): Promise<void>;
executionContext(): ExecutionContext;
getProperties(): Promise<Map<string, JSHandle>>;
@@ -305,7 +305,7 @@ export interface Response {
}
export interface FrameBase {
$(selector: string): Promise<ElementHandle>;
$(selector: string): Promise<ElementHandle | null>;
$$(selector: string): Promise<ElementHandle[]>;
$$eval(
selector: string,
@@ -349,7 +349,7 @@ export interface Frame extends FrameBase {
executionContext(): ExecutionContext;
isDetached(): boolean;
name(): string;
parentFrame(): Frame | undefined;
parentFrame(): Frame | null;
}
export interface EventObj {
@@ -396,9 +396,9 @@ export interface Page extends FrameBase {
focus(selector: string): Promise<void>;
frames(): Frame[];
getMetrics(): Metrics;
goBack(options?: Partial<NavigationOptions>): Promise<Response>;
goForward(options?: Partial<NavigationOptions>): Promise<Response>;
goto(url: string, options?: Partial<NavigationOptions>): Promise<Response>;
goBack(options?: Partial<NavigationOptions>): Promise<Response | null>;
goForward(options?: Partial<NavigationOptions>): Promise<Response | null>;
goto(url: string, options?: Partial<NavigationOptions>): Promise<Response | null>;
hover(selector: string): Promise<void>;
keyboard: Keyboard;
mainFrame(): Frame;
+5 -5
View File
@@ -151,7 +151,7 @@ puppeteer.launch().then(async browser => {
});
const inputElement = await page.$("input[type=submit]");
await inputElement.click();
if (inputElement) await inputElement.click();
});
// Example with launch options
@@ -178,9 +178,9 @@ puppeteer.launch().then(async browser => {
}
});
const page = await browser.newPage();
const button = await page.$("#myButton");
const div = await page.$("#myDiv");
const input = await page.$("#myInput");
const button = (await page.$("#myButton"))!;
const div = (await page.$("#myDiv"))!;
const input = (await page.$("#myInput"))!;
await page.addStyleTag({
url: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
@@ -223,7 +223,7 @@ puppeteer.launch().then(async browser => {
console.log(navResponse.ok, navResponse.status, navResponse.url, navResponse.headers);
// evaluate example
const bodyHandle = await page.$('body');
const bodyHandle = (await page.$('body'))!;
const html = await page.evaluate(body => body.innerHTML, bodyHandle);
await bodyHandle.dispose();