chore: mark Locator constructor as private (#10322)

This commit is contained in:
Alex Rudenko 2023-06-06 11:51:34 +02:00 committed by GitHub
parent 272f6c79f4
commit b81b019083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 36 deletions

View File

@ -1,27 +0,0 @@
---
sidebar_label: Locator.(constructor)
---
# Locator.(constructor)
Constructs a new instance of the `Locator` class
#### Signature:
```typescript
class Locator {
constructor(
pageOrFrame: Page | Frame,
selector: string,
options?: LocatorOptions
);
}
```
## Parameters
| Parameter | Type | Description |
| ----------- | ------------------------------------------------------------ | ------------ |
| pageOrFrame | [Page](./puppeteer.page.md) \| [Frame](./puppeteer.frame.md) | |
| selector | string | |
| options | [LocatorOptions](./puppeteer.locatoroptions.md) | _(Optional)_ |

View File

@ -14,12 +14,6 @@ export declare class Locator extends EventEmitter
**Extends:** [EventEmitter](./puppeteer.eventemitter.md) **Extends:** [EventEmitter](./puppeteer.eventemitter.md)
## Constructors
| Constructor | Modifiers | Description |
| ------------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------- |
| [(constructor)(pageOrFrame, selector, options)](./puppeteer.locator._constructor_.md) | | Constructs a new instance of the <code>Locator</code> class |
## Methods ## Methods
| Method | Modifiers | Description | | Method | Modifiers | Description |

View File

@ -356,7 +356,7 @@ export class Frame {
* change in the Locators API. * change in the Locators API.
*/ */
locator(selector: string): Locator { locator(selector: string): Locator {
return new Locator(this, selector); return Locator.create(this, selector);
} }
/** /**

View File

@ -117,11 +117,31 @@ export interface LocatorEventObject {
* @public * @public
*/ */
export class Locator extends EventEmitter { export class Locator extends EventEmitter {
/**
* @internal
*/
static create(
pageOrFrame: Page | Frame,
selector: string,
options: LocatorOptions = {
visibility: 'visible',
timeout:
'getDefaultTimeout' in pageOrFrame
? pageOrFrame.getDefaultTimeout()
: pageOrFrame.page().getDefaultTimeout(),
ensureElementIsInTheViewport: true,
waitForEnabled: true,
waitForStableBoundingBox: true,
}
): Locator {
return new Locator(pageOrFrame, selector, options);
}
#pageOrFrame: Page | Frame; #pageOrFrame: Page | Frame;
#selector: string; #selector: string;
#options: LocatorOptions; #options: LocatorOptions;
constructor( private constructor(
pageOrFrame: Page | Frame, pageOrFrame: Page | Frame,
selector: string, selector: string,
options: LocatorOptions = { options: LocatorOptions = {

View File

@ -827,7 +827,7 @@ export class Page extends EventEmitter {
* change in the Locators API. * change in the Locators API.
*/ */
locator(selector: string): Locator { locator(selector: string): Locator {
return new Locator(this, selector); return Locator.create(this, selector);
} }
/** /**