chore: rename $,$$ to readable names (#7848)

This commit is contained in:
Pavel Feldman 2021-07-26 15:46:51 -07:00 committed by GitHub
parent 95001fe8d1
commit d370f65713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -91,11 +91,11 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
}
async querySelector(params: channels.FrameQuerySelectorParams, metadata: CallMetadata): Promise<channels.FrameQuerySelectorResult> {
return { element: ElementHandleDispatcher.fromNullable(this._scope, await this._frame.$(params.selector)) };
return { element: ElementHandleDispatcher.fromNullable(this._scope, await this._frame.querySelector(params.selector)) };
}
async querySelectorAll(params: channels.FrameQuerySelectorAllParams, metadata: CallMetadata): Promise<channels.FrameQuerySelectorAllResult> {
const elements = await this._frame.$$(params.selector);
const elements = await this._frame.querySelectorAll(params.selector);
return { elements: elements.map(e => ElementHandleDispatcher.from(this._scope, e)) };
}

View File

@ -682,7 +682,7 @@ export class Frame extends SdkObject {
return value;
}
async $(selector: string): Promise<dom.ElementHandle<Element> | null> {
async querySelector(selector: string): Promise<dom.ElementHandle<Element> | null> {
debugLogger.log('api', ` finding element using the selector "${selector}"`);
return this._page.selectors._query(this, selector);
}
@ -736,7 +736,7 @@ export class Frame extends SdkObject {
}
async evalOnSelectorAndWaitForSignals(selector: string, expression: string, isFunction: boolean | undefined, arg: any): Promise<any> {
const handle = await this.$(selector);
const handle = await this.querySelector(selector);
if (!handle)
throw new Error(`Error: failed to find element matching selector "${selector}"`);
const result = await handle.evaluateExpressionAndWaitForSignals(expression, isFunction, true, arg);
@ -751,7 +751,7 @@ export class Frame extends SdkObject {
return result;
}
async $$(selector: string): Promise<dom.ElementHandle<Element>[]> {
async querySelectorAll(selector: string): Promise<dom.ElementHandle<Element>[]> {
return this._page.selectors._queryAll(this, selector, undefined, true /* adoptToMain */);
}
@ -1092,7 +1092,7 @@ export class Frame extends SdkObject {
const controller = new ProgressController(metadata, this);
return controller.run(async progress => {
progress.log(` checking visibility of "${selector}"`);
const element = await this.$(selector);
const element = await this.querySelector(selector);
return element ? await element.isVisible() : false;
}, this._page._timeoutSettings.timeout(options));
}