docs: converting Locator to FrameLocator (#10839)

This commit is contained in:
Yury Semikhatsky 2021-12-09 15:21:04 -08:00 committed by GitHub
parent 897e41c6c1
commit 4621f61c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View file

@ -71,6 +71,29 @@ await page.FrameLocator(".result-frame").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
- returns: <[FrameLocator]>

View file

@ -13608,6 +13608,15 @@ export interface FileChooser {
* 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 {
/**