You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] How to store Locator for element inside iframe? #9875
Since 1.14 pw provides Locators (https://playwright.dev/docs/api/class-locator). If i right, this is some sort of proxy to "store" actual element (each time i call method for Locator i will work with latests version of DOM element ). That's sound pretty good for conception of Page Object (PO). Instead of storing selectors inside PO and write boiler plate code for work with PO elements i can just define Locators and work with them.
But as i understand there is no such method for elements inside iframe.
For example, i can do this:
constconfirmButton=page.locator('selector');
In this case:
if element is not presented at this moment on the page -> it will wait until presented or throw (work like "waitForSelector"). Perfect 👍🏻
But if my element that i want to click present inside iframe, i should do something like:
In this case:
if iframe is not presented at this moment on the page -> it will throw an error because page.frame() for not existed frame will return null. Not perfect 😞
How can i store Locator for elements inside iframes that will also wait iframe first?
Activity
dgozman commentedon Oct 29, 2021
This is indeed an issue. We are tracking possible solutions in #7982.