Class: Playwright::FrameLocator
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::FrameLocator
- Defined in:
- lib/playwright_api/frame_locator.rb
Overview
FrameLocator represents a view to the ‘iframe` on the page. It captures the logic sufficient to retrieve the `iframe` and locate elements in that iframe. FrameLocator can be created with either [`method: Page.frameLocator`] or
- ‘method: Locator.frameLocator`
-
method.
“‘python sync locator = page.frame_locator(“my-frame”).locator(“text=Submit”) locator.click() “`
Strictness
Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches given selector.
“‘python sync # Throws if there are several frames in DOM: page.frame_locator(’.result-frame’).locator(‘button’).click()
# Works because we explicitly tell locator to pick the first frame: page.frame_locator(‘.result-frame’).first.locator(‘button’).click() “‘
Instance Method Summary collapse
-
#first ⇒ Object
Returns locator to the first matching frame.
-
#frame_locator(selector) ⇒ Object
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in that iframe.
-
#last ⇒ Object
Returns locator to the last matching frame.
-
#locator(selector) ⇒ Object
The method finds an element matching the specified selector in the FrameLocator’s subtree.
-
#nth(index) ⇒ Object
Returns locator to the n-th matching frame.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#first ⇒ Object
Returns locator to the first matching frame.
26 27 28 |
# File 'lib/playwright_api/frame_locator.rb', line 26 def first wrap_impl(@impl.first) end |
#frame_locator(selector) ⇒ Object
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in that iframe.
32 33 34 |
# File 'lib/playwright_api/frame_locator.rb', line 32 def frame_locator(selector) wrap_impl(@impl.frame_locator(unwrap_impl(selector))) end |
#last ⇒ Object
Returns locator to the last matching frame.
37 38 39 |
# File 'lib/playwright_api/frame_locator.rb', line 37 def last wrap_impl(@impl.last) end |
#locator(selector) ⇒ Object
The method finds an element matching the specified selector in the FrameLocator’s subtree.
42 43 44 |
# File 'lib/playwright_api/frame_locator.rb', line 42 def locator(selector) wrap_impl(@impl.locator(unwrap_impl(selector))) end |
#nth(index) ⇒ Object
Returns locator to the n-th matching frame.
47 48 49 |
# File 'lib/playwright_api/frame_locator.rb', line 47 def nth(index) wrap_impl(@impl.nth(unwrap_impl(index))) end |