lib/puppeteer/page.rb in puppeteer-ruby-0.0.16 vs lib/puppeteer/page.rb in puppeteer-ruby-0.0.17
- old
+ new
@@ -679,16 +679,18 @@
async_wait_for_navigation(timeout: timeout, wait_until: wait_until),
@client.async_send_message('Page.reload'),
).first
end
- # @param timeout [number|nil]
- # @param wait_until [string|nil] 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'
private def wait_for_navigation(timeout: nil, wait_until: nil)
main_frame.send(:wait_for_navigation, timeout: timeout, wait_until: wait_until)
end
+ # @!method async_wait_for_navigation(timeout: nil, wait_until: nil)
+ #
+ # @param timeout [number|nil]
+ # @param wait_until [string|nil] 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'
define_async_method :async_wait_for_navigation
private def wait_for_network_manager_event(event_name, predicate:, timeout:)
option_timeout = timeout || @timeout_settings.timeout
@@ -723,17 +725,10 @@
future.reject(Puppeteer::CDPSession::Error.new('Target Closed'))
end
end
end
- # - Waits until request URL matches
- # `wait_for_request(url: 'https://example.com/awesome')`
- # - Waits until request matches the given predicate
- # `wait_for_request(predicate: -> (req){ req.url.start_with?('https://example.com/search') })`
- #
- # @param url [String]
- # @param predicate [Proc(Puppeteer::Request -> Boolean)]
private def wait_for_request(url: nil, predicate: nil, timeout: nil)
if !url && !predicate
raise ArgumentError.new('url or predicate must be specified')
end
if predicate && !predicate.is_a?(Proc)
@@ -750,14 +745,24 @@
predicate: request_predicate,
timeout: timeout,
)
end
- define_async_method :async_wait_for_request
-
+ # @!method async_wait_for_request(url: nil, predicate: nil, timeout: nil)
+ #
+ # Waits until request URL matches or request matches the given predicate.
+ #
+ # Waits until request URL matches
+ # wait_for_request(url: 'https://example.com/awesome')
+ #
+ # Waits until request matches the given predicate
+ # wait_for_request(predicate: -> (req){ req.url.start_with?('https://example.com/search') })
+ #
# @param url [String]
# @param predicate [Proc(Puppeteer::Request -> Boolean)]
+ define_async_method :async_wait_for_request
+
private def wait_for_response(url: nil, predicate: nil, timeout: nil)
if !url && !predicate
raise ArgumentError.new('url or predicate must be specified')
end
if predicate && !predicate.is_a?(Proc)
@@ -774,10 +779,14 @@
predicate: response_predicate,
timeout: timeout,
)
end
+ # @!method async_wait_for_response(url: nil, predicate: nil, timeout: nil)
+ #
+ # @param url [String]
+ # @param predicate [Proc(Puppeteer::Request -> Boolean)]
define_async_method :async_wait_for_response
# @param timeout [number|nil]
# @param wait_until [string|nil] 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'
def go_back(timeout: nil, wait_until: nil)
@@ -1069,11 +1078,22 @@
end
define_async_method :async_select
# @param selector [String]
- def tap(selector)
- main_frame.tap(selector)
+ def tap(selector: nil, &block)
+ # resolves double meaning of tap.
+ if selector.nil? && block
+ # Original usage of Object#tap.
+ #
+ # browser.new_page.tap do |page|
+ # ...
+ # end
+ super(&block)
+ else
+ # Puppeteer's Page#tap.
+ main_frame.tap(selector)
+ end
end
define_async_method :async_tap
# @param selector [String]