@@ -87,6 +87,12 @@ export const page: {
8787 * Wrap an HTML element in a `Locator`. When querying for elements, the search will always return this element.
8888 */
8989 elementLocator(element : Element ): Locator
90+ /**
91+ * The iframe locator. This is a document locator that enters the iframe body
92+ * and works similarly to the `page` object.
93+ * **Warning:** At the moment, this is supported only by the `playwright` provider.
94+ */
95+ frameLocator(iframeElement : Locator ): FrameLocator
9096
9197 /**
9298 * Locator APIs. See its documentation for more details.
@@ -110,8 +116,37 @@ Note that `screenshot` will always return a base64 string if `save` is set to `f
110116The ` path ` is also ignored in that case.
111117:::
112118
119+ ### frameLocator
120+
121+ ` ` ` ts
122+ function frameLocator(iframeElement : Locator ): FrameLocator
123+ ```
124+
125+ The ` frameLocator ` method returns a ` FrameLocator ` instance that can be used to find elements inside the iframe .
126+
127+ The frame locator is similar to ` page ` . It does not refer to the Iframe HTML element , but to the iframe ' s document.
128+
129+ ` ` ` ts
130+ const frame = page.frameLocator(
131+ page.getByTestId('iframe')
132+ )
133+
134+ await frame.getByText('Hello World').click() // ✅
135+ await frame.click() // ❌ Not available
136+ ` ` `
137+
138+ ::: danger IMPORTANT
139+ At the moment , the ` frameLocator ` method is only supported by the ` playwright ` provider .
140+
141+ The interactive methods (like ` click ` or ` fill ` ) are always available on elements within the iframe , but assertions with ` expect.element ` require the iframe to have the [same - origin policy ](https :// developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy).
142+ :::
143+
113144## ` cdp `
114145
146+ ` ` ` ts
147+ function cdp(): CDPSession
148+ ` ` `
149+
115150The ` cdp ` export returns the current Chrome DevTools Protocol session . It is mostly useful to library authors to build tools on top of it .
116151
117152::: warning
0 commit comments