docs: converting Locator to FrameLocator (#10839)
This commit is contained in:
parent
897e41c6c1
commit
4621f61c7d
|
|
@ -71,6 +71,29 @@ await page.FrameLocator(".result-frame").Locator("button").ClickAsync();
|
||||||
await page.FrameLocator(".result-frame").First.Locator("button").ClickAsync();
|
await page.FrameLocator(".result-frame").First.Locator("button").ClickAsync();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Converting Locator to FrameLocator**
|
||||||
|
|
||||||
|
If you have a [Locator] object pointing to an `iframe` it can be converted to [FrameLocator] using [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const frameLocator = locator.frameLocator(':scope');
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
Locator frameLocator = locator.frameLocator(':scope');
|
||||||
|
```
|
||||||
|
|
||||||
|
```python async
|
||||||
|
frameLocator = locator.frame_locator(":scope");
|
||||||
|
```
|
||||||
|
|
||||||
|
```python sync
|
||||||
|
frameLocator = locator.frame_locator(":scope");
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var frameLocator = locator.FrameLocator(":scope");
|
||||||
|
```
|
||||||
|
|
||||||
## method: FrameLocator.first
|
## method: FrameLocator.first
|
||||||
- returns: <[FrameLocator]>
|
- returns: <[FrameLocator]>
|
||||||
|
|
|
||||||
9
packages/playwright-core/types/types.d.ts
vendored
9
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -13608,6 +13608,15 @@ export interface FileChooser {
|
||||||
* await page.frameLocator('.result-frame').first().locator('button').click();
|
* await page.frameLocator('.result-frame').first().locator('button').click();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
* **Converting Locator to FrameLocator**
|
||||||
|
*
|
||||||
|
* If you have a [Locator] object pointing to an `iframe` it can be converted to [FrameLocator] using
|
||||||
|
* [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const frameLocator = locator.frameLocator(':scope');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
export interface FrameLocator {
|
export interface FrameLocator {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue