mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: mark Locator constructor as private (#10322)
This commit is contained in:
parent
272f6c79f4
commit
b81b019083
@ -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)_ |
|
@ -14,12 +14,6 @@ export declare class Locator extends EventEmitter
|
||||
|
||||
**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
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
|
@ -356,7 +356,7 @@ export class Frame {
|
||||
* change in the Locators API.
|
||||
*/
|
||||
locator(selector: string): Locator {
|
||||
return new Locator(this, selector);
|
||||
return Locator.create(this, selector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,11 +117,31 @@ export interface LocatorEventObject {
|
||||
* @public
|
||||
*/
|
||||
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;
|
||||
#selector: string;
|
||||
#options: LocatorOptions;
|
||||
|
||||
constructor(
|
||||
private constructor(
|
||||
pageOrFrame: Page | Frame,
|
||||
selector: string,
|
||||
options: LocatorOptions = {
|
||||
|
@ -827,7 +827,7 @@ export class Page extends EventEmitter {
|
||||
* change in the Locators API.
|
||||
*/
|
||||
locator(selector: string): Locator {
|
||||
return new Locator(this, selector);
|
||||
return Locator.create(this, selector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user