Class: Puppeteer::Bidi::FunctionLocator
- Defined in:
- lib/puppeteer/bidi/locator.rb,
sig/puppeteer/bidi/locator.rbs
Overview
Locator implementation based on JavaScript functions.
Constant Summary
Constants inherited from Locator
Instance Attribute Summary
Attributes inherited from Locator
#ensure_element_is_in_viewport, #timeout, #visibility, #wait_for_enabled, #wait_for_stable_bounding_box
Class Method Summary collapse
Instance Method Summary collapse
- #_clone ⇒ Object
- #_wait(timeout_ms:, deadline:) ⇒ Object
-
#initialize(page_or_frame, function) ⇒ FunctionLocator
constructor
A new instance of FunctionLocator.
Methods inherited from Locator
#build_deadline, #click, #clone, #copy_options, #ensure_element_is_in_viewport?, #ensure_element_is_in_viewport_if_needed, #fill, #fill_directly, #filter, #hover, #map, #map_handle, #off, #on, #once, #perform_action, race, #raise_timeout, #remaining_time_ms, #scroll, #set_ensure_element_is_in_the_viewport, #set_timeout, #set_visibility, #set_wait_for_enabled, #set_wait_for_stable_bounding_box, #wait, #wait_for_enabled?, #wait_for_enabled_if_needed, #wait_for_stable_bounding_box?, #wait_for_stable_bounding_box_if_needed, #wait_handle, #wait_until, #with_retry
Constructor Details
#initialize(page_or_frame, function) ⇒ FunctionLocator
Returns a new instance of FunctionLocator.
547 548 549 550 551 |
# File 'lib/puppeteer/bidi/locator.rb', line 547 def initialize(page_or_frame, function) super() @page_or_frame = page_or_frame @function = function end |
Class Method Details
.create(page_or_frame, function) ⇒ Locator
538 539 540 541 542 543 544 545 |
# File 'lib/puppeteer/bidi/locator.rb', line 538 def self.create(page_or_frame, function) timeout = if page_or_frame.respond_to?(:default_timeout) page_or_frame.default_timeout else page_or_frame.page.default_timeout end new(page_or_frame, function).set_timeout(timeout) end |
Instance Method Details
#_clone ⇒ Object
555 556 557 |
# File 'lib/puppeteer/bidi/locator.rb', line 555 def _clone FunctionLocator.new(@page_or_frame, @function).(self) end |
#_wait(timeout_ms:, deadline:) ⇒ Object
559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/puppeteer/bidi/locator.rb', line 559 def _wait(timeout_ms:, deadline:) handle = @page_or_frame.evaluate_handle(@function) begin truthy = handle.evaluate("(value) => Boolean(value)") raise RetryableError unless truthy handle rescue StandardError handle.dispose raise end end |