Skip to content

Commit 4c86629

Browse files
added iframe page object example (#110)
1 parent f19d64f commit 4c86629

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

versioned_docs/version-2x/Guides/page-object.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ Native locators allow you to leverage the full power of your testing framework's
214214
// Using the argument from feature file
215215
DynamicElement = locator.native(({ page, argument }) =>
216216
page.getByRole('button', { name: argument }));
217+
218+
// Element in iframe
219+
ElementInIframe = locator.native(({ page }) => page.frameLocator('iframe#yourIframe').locator('#element'));
217220
}
218221
```
219222
</TabItem>
@@ -224,7 +227,7 @@ Native locators allow you to leverage the full power of your testing framework's
224227

225228
class App {
226229
// Using Playwright's getByRole
227-
SubmitButton = locator.native(({ page }: { page: Page }) =>
230+
SubmitButton = locator.native(({ page }: { page: Page }) =>
228231
page.getByRole('button', { name: 'Submit' }));
229232

230233
// Using Playwright's getByText with regex
@@ -242,6 +245,9 @@ Native locators allow you to leverage the full power of your testing framework's
242245
// Using the argument from feature file
243246
DynamicElement = locator.native(({ page, argument }: { page: Page, argument: string }) =>
244247
page.getByRole('button', { name: argument }));
248+
249+
// Element in iframe
250+
ElementInIframe = locator.native(({ page }: { page: Page }) => page.frameLocator('iframe#yourIframe').locator('#element'));
245251
}
246252
```
247253
</TabItem>

0 commit comments

Comments
 (0)