Rayrun
← Back to Discord Forum

[Microsoft/Playwright.Net] How to find if a FrameLocator selects a number of FrameLocators?

As the title says, how would I go about figuring out how many frame locators are selected?

Locator.CountAsync() exists but there's no FrameLocator.CountAsync() equivalent...

This thread is trying to answer question "How to find if a FrameLocator selects a number of FrameLocators in Playwright.Net?"

7 replies

childFrames() ?

@dand33 thanks, but that works on elementhandles but not locators. It seems like I should submit a feature request. And I can get the element out of a locator using EvaluateAsync.

SO, a roundabout way to implement is to do

var element = await locator.EvaluateAsync("node => node"); Frame frame = element as Frame; return frame.ChildFrames;

doesn't frame.frameLocator() give you a locator?

@dand33: @dand33 frame.FrameLocator requires a string selector argument and seaches INSIDE the frame.

@dand33 frame.FrameLocator requires a string selector argument and seaches INSIDE the frame.

Not sure you can't get what you need. Not 100% but if you call childFrames you should be able to get all the given frames. Once you get a frame, you should be able to get the attribute(s) for either the src='...' or name='...' attributes can't have a frame without the src atleast Now fix up the properties fetched and derived a locator for the given frame element...?

Thanks @dand33. The original problem was that FrameLocator does not have a Count or CountAsync method. You can not figure out given a FrameLocator if it references one or many FrameLocators.

I will submit a feature request.

childFrames returns an array, and you have a count now? I'm missing what you can't get if you go after what you can?

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].