class Appium::Driver
def initialize opts={}
-
(Driver)
-
Parameters:
-
opts
(Object
) -- A hash containing various options.
def initialize opts={} # quit last driver $driver.driver_quit if $driver opts = {} if opts.nil? # convert to downcased symbols opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v } @custom_url = opts.fetch :server_url, false @compress_xml = opts[:compress_xml] ? true : false @export_session = opts.fetch :export_session, false @default_wait = opts.fetch :wait, 30 # Path to the .apk, .app or .app.zip. # The path can be local or remote for Sauce. @app_path = opts.fetch :app_path, ENV['APP_PATH'] raise 'APP_PATH must be set.' if @app_path.nil? # The name to use for the test run on Sauce. @app_name = opts.fetch :app_name, ENV['APP_NAME'] # Android app package @app_package = opts.fetch :app_package, ENV['APP_PACKAGE'] # Android app starting activity. @app_activity = opts.fetch :app_activity, ENV['APP_ACTIVITY'] # Android app waiting activity @app_wait_activity = opts.fetch :app_wait_activity, ENV['APP_WAIT_ACTIVITY'] # Sauce Username @sauce_username = opts.fetch :sauce_username, ENV['SAUCE_USERNAME'] # Sauce Key @sauce_access_key = opts.fetch :sauce_access_key, ENV['SAUCE_ACCESS_KEY'] @port = opts.fetch :port, ENV['PORT'] || 4723 # device as used in device capabilities. # iOS only. # # Android is always Android or Selendroid so there's no # override required. @device_cap = opts.fetch :device_cap, false # :ios, :android, :selendroid @device = opts.fetch :device, ENV['DEVICE'] || :ios @device = @device.intern # device must be a symbol # load common methods extend Appium::Common if @device == :android raise 'APP_ACTIVITY must be set.' if @app_activity.nil? # load Android specific methods extend Appium::Android else # load iOS specific methods extend Appium::Ios end # apply os specific patches patch_webdriver_element # enable debug patch # !!'constant' == true @debug = opts.fetch :debug, !!defined?(Pry) puts "Debug is: #{@debug}" if @debug ap opts unless opts.empty? puts "Device is: #{@device}" patch_webdriver_bridge end # Save global reference to last created Appium driver for top level methods. $driver = self # Promote exactly once the first time the driver is created. # Subsequent drivers do not trigger promotion. unless @@loaded @@loaded = true # Promote only on Minitest::Spec (minitest 5) by default Appium.promote_appium_methods ::Minitest::Spec end self # return newly created driver end # def initialize