lib/appium_lib/driver.rb in appium_lib-8.0.2 vs lib/appium_lib/driver.rb in appium_lib-8.1.0

- old
+ new

@@ -261,10 +261,12 @@ attr_accessor :appium_port # Device type to request from the appium server attr_accessor :appium_device # Boolean debug mode for the Appium Ruby bindings attr_accessor :appium_debug + # instance of AbstractEventListener for logging support + attr_accessor :listener # Returns the driver # @return [Driver] the driver attr_reader :driver @@ -307,10 +309,14 @@ @sauce_username = nil if !@sauce_username || (@sauce_username.is_a?(String) && @sauce_username.empty?) @sauce_access_key = appium_lib_opts.fetch :sauce_access_key, ENV['SAUCE_ACCESS_KEY'] @sauce_access_key = nil if !@sauce_access_key || (@sauce_access_key.is_a?(String) && @sauce_access_key.empty?) @appium_port = appium_lib_opts.fetch :port, 4723 + # to pass it in Selenium.new. + # `listener = opts.delete(:listener)` is called in Selenium::Driver.new + @listener = appium_lib_opts.fetch :listener, nil + # Path to the .apk, .app or .app.zip. # The path can be local or remote for Sauce. if @caps && @caps[:app] && ! @caps[:app].empty? @caps[:app] = self.class.absolute_app_path opts end @@ -359,11 +365,12 @@ last_waits: @last_waits, sauce_username: @sauce_username, sauce_access_key: @sauce_access_key, port: @appium_port, device: @appium_device, - debug: @appium_debug + debug: @appium_debug, + listener: @listener } # Return duplicates so attributes are immutable attributes.each do |key, value| attributes[key] = value.duplicable? ? value.dup : value @@ -433,11 +440,11 @@ # Get the server url # @return [String] the server url def server_url return @custom_url if @custom_url if !@sauce_username.nil? && !@sauce_access_key.nil? - "http://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:80/wd/hub" + "https://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:443/wd/hub" else "http://127.0.0.1:#{@appium_port}/wd/hub" end end @@ -474,11 +481,16 @@ @client ||= Selenium::WebDriver::Remote::Http::Default.new @client.timeout = 999_999 begin driver_quit - @driver = Selenium::WebDriver.for :remote, http_client: @client, desired_capabilities: @caps, url: server_url + @driver = Selenium::WebDriver.for(:remote, + http_client: @client, + desired_capabilities: @caps, + url: server_url, + listener: @listener) + # Load touch methods. @driver.extend Selenium::WebDriver::DriverExtensions::HasTouchScreen @driver.extend Selenium::WebDriver::DriverExtensions::HasLocation # export session @@ -487,10 +499,10 @@ File.open('/tmp/appium_lib_session', 'w') do |f| f.puts @driver.session_id end rescue nil end rescue Errno::ECONNREFUSED - raise 'ERROR: Unable to connect to Appium. Is the server running?' + raise "ERROR: Unable to connect to Appium. Is the server running on #{server_url}?" end @driver.manage.timeouts.implicit_wait = @default_wait @driver