lib/appium_lib/driver.rb in appium_lib-9.7.1 vs lib/appium_lib/driver.rb in appium_lib-9.7.2

- old
+ new

@@ -61,53 +61,50 @@ # Creates a new driver. The driver is defined as global scope by default. # We can avoid defining global driver. # # @example # - # ```ruby - # require 'rubygems' - # require 'appium_lib' + # require 'rubygems' + # require 'appium_lib' # - # # platformName takes a string or a symbol. - # - # # Start iOS driver with global scope - # opts = { - # caps: { - # platformName: :ios, - # app: '/path/to/MyiOS.app' - # }, - # appium_lib: { - # wait_timeout: 30 - # } + # # platformName takes a string or a symbol. + # # Start iOS driver with global scope + # opts = { + # caps: { + # platformName: :ios, + # app: '/path/to/MyiOS.app' + # }, + # appium_lib: { + # wait_timeout: 30 # } - # Appium::Driver.new(opts, true).start_driver + # } + # Appium::Driver.new(opts, true).start_driver # - # # Start Android driver with global scope - # opts = { - # caps: { - # platformName: :android, - # app: '/path/to/my.apk' - # }, - # appium_lib: { - # wait_timeout: 30, - # wait_interval: 1 - # } + # # Start Android driver with global scope + # opts = { + # caps: { + # platformName: :android, + # app: '/path/to/my.apk' + # }, + # appium_lib: { + # wait_timeout: 30, + # wait_interval: 1 # } - # Appium::Driver.new(opts, true).start_driver + # } + # Appium::Driver.new(opts, true).start_driver # - # # Start iOS driver without global scope - # opts = { - # caps: { - # platformName: :ios, - # app: '/path/to/MyiOS.app' - # }, - # appium_lib: { - # wait_timeout: 30 - # } + # # Start iOS driver without global scope + # opts = { + # caps: { + # platformName: :ios, + # app: '/path/to/MyiOS.app' + # }, + # appium_lib: { + # wait_timeout: 30 # } - # Appium::Driver.new(opts, false).start_driver - # ``` + # } + # Appium::Driver.new(opts, false).start_driver # # @param opts [Object] A hash containing various options. # @param global_driver [Bool] A bool require global driver before initialize. # @return [Driver] def initialize(opts = {}, global_driver = nil) @@ -277,18 +274,17 @@ true end # Returns the server's version info # - # ```ruby - # { + # @example + # { # "build" => { # "version" => "0.18.1", # "revision" => "d242ebcfd92046a974347ccc3a28f0e898595198" # } - # } - # ``` + # } # # @return [Hash] def appium_server_version @core.appium_server_version rescue Selenium::WebDriver::Error::WebDriverError => ex @@ -309,16 +305,16 @@ platform_version end # Returns the client's version info # - # ```ruby - # { - # "version" => "9.1.1" - # } - # ``` + # @example # + # { + # "version" => "9.1.1" + # } + # # @return [Hash] def appium_client_version { version: ::Appium::VERSION } end @@ -376,12 +372,14 @@ start_driver end # Takes a png screenshot and saves to the target path. # - # Example: screenshot '/tmp/hi.png' + # @example # + # screenshot '/tmp/hi.png' + # # @param png_save_path [String] the full path to save the png # @return [nil] def screenshot(png_save_path) @core.screenshot png_save_path end @@ -395,38 +393,39 @@ # Get the device window's size. # @return [Selenium::WebDriver::Dimension] # # @example + # # size = @driver.window_size # size.width #=> Integer # size.height #=> Integer + # def window_size @driver.window_size end # Creates a new global driver and quits the old one if it exists. # You can customise http_client as the following # # @example - # ```ruby - # require 'rubygems' - # require 'appium_lib' # - # # platformName takes a string or a symbol. + # require 'rubygems' + # require 'appium_lib' # - # # Start iOS driver - # opts = { - # caps: { - # platformName: :ios, - # app: '/path/to/MyiOS.app' - # }, - # appium_lib: { - # wait_timeout: 30 - # } + # # platformName takes a string or a symbol. + # # Start iOS driver + # opts = { + # caps: { + # platformName: :ios, + # app: '/path/to/MyiOS.app' + # }, + # appium_lib: { + # wait_timeout: 30 # } - # Appium::Driver.new(opts).start_driver + # } + # Appium::Driver.new(opts).start_driver # # @option http_client_ops [Hash] :http_client Custom HTTP Client # @option http_client_ops [Hash] :open_timeout Custom open timeout for http client. # @option http_client_ops [Hash] :read_timeout Custom read timeout for http client. # @return [Selenium::WebDriver] the new global driver @@ -468,16 +467,16 @@ @driver.manage.timeouts.implicit_wait = 0 end # Set implicit wait. Default to @core.default_wait. # - # ```ruby - # set_wait 2 - # set_wait # @core.default_wait + # @example # - # ``` + # set_wait 2 + # set_wait # @core.default_wait # + # # @param timeout [Integer] the timeout in seconds # @return [void] def set_wait(timeout = nil) timeout = @core.default_wait if timeout.nil? @driver.manage.timeouts.implicit_wait = timeout @@ -524,23 +523,21 @@ end # Calls @driver.find_elements_with_appium # # @example - # ```ruby - # @driver = Appium::Driver.new(opts, false) - # @driver.find_elements :predicate, yyy - # ``` # + # @driver = Appium::Driver.new(opts, false) + # @driver.find_elements :predicate, yyy + # # If you call `Appium.promote_appium_methods`, you can call `find_elements` directly. # # @example - # ```ruby - # @driver = Appium::Driver.new(opts, false) - # @driver.find_elements :predicate, yyy - # ``` # + # @driver = Appium::Driver.new(opts, false) + # @driver.find_elements :predicate, yyy + # # If you call `Appium.promote_appium_methods`, you can call `find_elements` directly. # # @param [*args] args The args to use # @return [Array<Element>] Array is empty when no elements are found. def find_elements(*args) @@ -548,15 +545,14 @@ end # Calls @driver.find_element # # @example - # ```ruby - # @driver = Appium::Driver.new(opts, false) - # @driver.find_element :accessibility_id, zzz - # ``` # + # @driver = Appium::Driver.new(opts, false) + # @driver.find_element :accessibility_id, zzz + # # If you call `Appium.promote_appium_methods`, you can call `find_element` directly. # # @param [*args] args The args to use # @return [Element] def find_element(*args) @@ -583,19 +579,9 @@ # quit and exit are reserved by Pry. # @return [void] def x driver_quit exit # exit pry - end - - private - - # @private - def write_session_id(session_id) - File.open('/tmp/appium_lib_session', 'w') { |f| f.puts session_id } - rescue IOError => e - ::Appium::Logger.warn e - nil end end # class Driver end # module Appium # Paging in Pry is annoying :q required to exit.