lib/appium_lib/driver.rb in appium_lib-10.4.1 vs lib/appium_lib/driver.rb in appium_lib-10.5.0
- old
+ new
@@ -796,9 +796,51 @@
longitude = opts.fetch(:longitude)
altitude = opts.fetch(:altitude, 75)
@driver.set_location(latitude, longitude, altitude)
end
+ # @since Appium 1.16.0
+ #
+ # Logs a custom event. The event is available via {::Appium::Core::Events#get} or
+ # <code>driver.session_capabilities['events']</code> with <code>eventTimings</code> capabilities.
+ #
+ # @param [String] vendor The vendor prefix for the event
+ # @param [String] event The name of event
+ # @returns [nil]
+ #
+ # @example
+ #
+ # log_event vendor: 'appium', event: 'funEvent'
+ #
+ # log_event = { vendor: 'appium', event: 'anotherEvent' }
+ # log_events #=> {...., 'appium:funEvent' => [1572957315, 1572960305],
+ # # 'appium:anotherEvent' => 1572959315}
+ #
+ def log_event(vendor:, event:)
+ @driver.logs.event vendor: vendor, event: event
+ end
+
+ def log_event=(log_event)
+ raise ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}') unless log_event.is_a?(Hash)
+
+ @driver.logs.event vendor: log_event[:vendor], event: log_event[:event]
+ end
+
+ # @since Appium 1.16.0
+ # Returns events with filtering with 'type'. Defaults to all available events.
+ #
+ # @param [String] type The type of events to get
+ # @return [Hash]
+ #
+ # @example
+ #
+ # log_events #=> {}
+ # log_events #=> {'commands' => [{'cmd' => 123455, ....}], 'startTime' => 1572954894127, }
+ #
+ def log_events(type = nil)
+ @driver.logs.events(type)
+ end
+
# Quit the driver and Pry.
# quit and exit are reserved by Pry.
# @return [void]
def x
driver_quit