Method: Capybara::Node::Finders#ancestor
- Defined in:
- lib/capybara/node/finders.rb
#ancestor(*args, **options, &optional_filter_block) ⇒ Capybara::Node::Element
Find an Element based on the given arguments that is also an ancestor of the element called on. #ancestor will raise an error if the element is not found.
#ancestor takes the same options as #find.
element.ancestor('#foo').find('.bar')
element.ancestor(:xpath, './/div[contains(., "bar")]')
element.ancestor('ul', text: 'Quox').click_link('Delete')
If the driver is capable of executing JavaScript, this method will wait for a set amount of time and continuously retry finding the element until either the element is found or the time expires. The length of time this method will wait is controlled through default_max_wait_time.
81 82 83 84 |
# File 'lib/capybara/node/finders.rb', line 81 def ancestor(*args, **, &optional_filter_block) [:session_options] = synced_resolve Capybara::Queries::AncestorQuery.new(*args, **, &optional_filter_block) end |