playwright
playwright copied to clipboard
[Feature]: Expose isVisible(), etc... to frameLocator, frame, etc...
🚀 Feature Request
We currently have isVisible(), isHidden(), isEnabled(), etc.... available for locators.
Is it possible to expose these methods to other elements such as: frameLocator, frame, etc.... ?
Asking because: One of the websites I am working on have many frameLocators and frames, and depending on the situation, they might be visible or hidden, and I would like to have the ability to check on them.
Example
No response
Motivation
I think this feature might become handy to others as well if they are working on similar websites like the one I am working with.
@qk5 In scenarios similar to yours, we recommend to use Locator
s to identify the frame element. You can convert Locator
to FrameLocator
at any moment - see "Converting Locator to FrameLocator" section in FrameLocator
docs. Let me know whether that works for you.
I hope playwright will expose isVisible() and others for frameLocators. It takes a long time to validate frameLocators with many frames involved.
@dgozman
Thank you for the suggestion.
While your proposal is effective, I still believe it would be beneficial to expose methods like isVisible()
, isEnabled()
, and highlight()
, etc., to FrameLocators
and Frames
. I will do my best to describe my use case below, and please feel free to correct me if I am mistaken.
Our internal website incorporates numerous web services pulled from various microservices. On the homepage alone, we have up to six levels of iframes, each representing a microservice displayed within layers of iframes. It's worth noting that although the contents within each iframe may differ, iframe names can overlap with each other.
For example, here is a high-level representation of locators I observe from my homepage:
-
page.frameLocator(frame1).frameLocator(frame2).frameLocator(frame3).frameLocator(frame4).frameLocator(frame5).frameLocator(frame6).locator();
-
page.frameLocator(frame1).frameLocator(frame2).frameLocator(frame3).locator();
-
page.frameLocator(frame1).frameLocator(frame4).frameLocator(frame5).locator();
-
page.frameLocator(frame1).frameLocator(frame6).locator();
-
page.frameLocator(frame1).frameLocator(frame6).frameLocator(frame2).locator();
-
etc...
In my case, having isVisible()
and especially highlight()
exposed will enable me to focus on all the locators associated with a particular iframe, and makes it easier to troubleshoot.
After discussing with the team, it seems like the best solution would be to introduce Locator
<-> FrameLocator
conversions, something like Locator.enterFrame()
and FrameLocator.exitFrame()
. This way you can always call Locator
methods by first converting the FrameLocator
into a Locator
.