Class: Puppeteer::FilteredLocator

Inherits:
DelegatedLocator show all
Defined in:
lib/puppeteer/locators.rb,
sig/puppeteer/locators.rbs

Constant Summary

Constants inherited from Locator

Locator::RETRY_DELAY_SECONDS

Instance Method Summary collapse

Methods inherited from DelegatedLocator

#delegate, #set_ensure_element_is_in_the_viewport, #set_timeout, #set_visibility, #set_wait_for_enabled, #set_wait_for_stable_bounding_box

Methods inherited from Locator

#click, #clone, #copy_options, #fill, #filter, #filter_handle, function_string?, #hover, #map, #map_handle, #on, #once, race, #scroll, #set_ensure_element_is_in_the_viewport, #set_timeout, #set_visibility, #set_wait_for_enabled, #set_wait_for_stable_bounding_box, #timeout, #wait, #wait_handle

Methods included from EventCallbackable

#add_event_listener, #emit_event, #observe_first, #off, #on_event, #remove_event_listener

Constructor Details

#initialize(base, predicate) ⇒ FilteredLocator

Returns a new instance of FilteredLocator.

Parameters:

  • base (Object)
  • predicate (Object)


643
644
645
646
# File 'lib/puppeteer/locators.rb', line 643

def initialize(base, predicate)
  super(base)
  @predicate = predicate
end

Instance Method Details

#_cloneObject

Returns:

  • (Object)


648
649
650
# File 'lib/puppeteer/locators.rb', line 648

protected def _clone
  self.class.new(delegate.clone, @predicate).copy_options(self)
end

#_wait(options) ⇒ Object

Parameters:

  • options (Object)

Returns:

  • (Object)

Raises:



652
653
654
655
656
657
658
# File 'lib/puppeteer/locators.rb', line 652

protected def _wait(options)
  handle = delegate.send(:_wait, options)
  result = @predicate.call(handle, options)
  return handle if result

  raise Puppeteer::Error.new('Locator predicate did not match')
end