class Playwright::FrameLocator

“‘
frameLocator = locator.frame_locator(“:scope”);
“`python sync<br><br>(developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
If you have a `Locator` object pointing to an `iframe` it can be converted to `FrameLocator` using
**Converting Locator to FrameLocator**
“`
page.frame_locator(’.result-frame’).first.locator(‘button’).click()
# Works because we explicitly tell locator to pick the first frame:
page.frame_locator(‘.result-frame’).locator(‘button’).click()
# Throws if there are several frames in DOM:
“‘python sync
given selector.
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
Strictness
“`
locator.click()
locator = page.frame_locator(“my-frame”).locator(“text=Submit”)
“`python sync
[`method: Locator.frameLocator`] method.
and locate elements in that iframe. FrameLocator can be created with either [`method: Page.frameLocator`] or
FrameLocator represents a view to the `iframe` on the page. It captures the logic sufficient to retrieve the `iframe`

def first

Returns locator to the first matching frame.
def first
  wrap_impl(@impl.first)
end

def frame_locator(selector)

that iframe.
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
def frame_locator(selector)
  wrap_impl(@impl.frame_locator(unwrap_impl(selector)))
end

def last

Returns locator to the last matching frame.
def last
  wrap_impl(@impl.last)
end

def locator(selector, hasText: nil)

The method finds an element matching the specified selector in the FrameLocator's subtree.
def locator(selector, hasText: nil)
  wrap_impl(@impl.locator(unwrap_impl(selector), hasText: unwrap_impl(hasText)))
end

def nth(index)

Returns locator to the n-th matching frame.
def nth(index)
  wrap_impl(@impl.nth(unwrap_impl(index)))
end