lib/appium_lib/driver.rb in appium_lib-9.1.3 vs lib/appium_lib/driver.rb in appium_lib-9.2.0
- old
+ new
@@ -278,22 +278,21 @@
attr_accessor :export_session
# Default wait time for elements to appear
# Returns the default client side wait.
# This value is independent of what the server is using
# @return [Integer]
- attr_accessor :default_wait
- # Array of previous wait time values
- attr_accessor :last_waits
+ attr_reader :default_wait
# Username for use on Sauce Labs
attr_accessor :sauce_username
# Access Key for use on Sauce Labs
attr_accessor :sauce_access_key
# Appium's server port
attr_accessor :appium_port
# Device type to request from the appium server
attr_accessor :appium_device
- # Automation name sent to appium server
+ # Automation name sent to appium server or received from server
+ # If automation_name is nil, it is not set both client side and server side.
attr_reader :automation_name
# Appium's server version
attr_reader :appium_server_version
# Boolean debug mode for the Appium Ruby bindings
attr_accessor :appium_debug
@@ -338,11 +337,10 @@
# appium_lib specific values
@custom_url = appium_lib_opts.fetch :server_url, false
@export_session = appium_lib_opts.fetch :export_session, false
@default_wait = appium_lib_opts.fetch :wait, 0
- @last_waits = [@default_wait]
@sauce_username = appium_lib_opts.fetch :sauce_username, ENV['SAUCE_USERNAME']
@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
@@ -399,14 +397,14 @@
# Returns a hash of the driver attributes
def driver_attributes
attributes = {
caps: @caps,
+ automation_name: @automation_name,
custom_url: @custom_url,
export_session: @export_session,
default_wait: @default_wait,
- last_waits: @last_waits,
sauce_username: @sauce_username,
sauce_access_key: @sauce_access_key,
port: @appium_port,
device: @appium_device,
debug: @appium_debug,
@@ -548,10 +546,11 @@
# Creates a new global driver and quits the old one if it exists.
#
# @return [Selenium::WebDriver] the new global driver
def start_driver
+ # open_timeout and read_timeout are explicit wait.
@http_client ||= Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 999_999, read_timeout: 999_999)
begin
driver_quit
@driver = Selenium::WebDriver.for(:remote,
@@ -576,48 +575,34 @@
end
@appium_server_version = appium_server_version
check_server_version_xcuitest
+ set_automation_name_if_nil
@driver.manage.timeouts.implicit_wait = @default_wait
@driver
end
- # Set implicit wait and default_wait to zero.
+ # Set implicit wait to zero.
def no_wait
- @last_waits = [@default_wait, 0]
- @default_wait = 0
@driver.manage.timeouts.implicit_wait = 0
end
- # Set implicit wait and default_wait to timeout, defaults to 30.
- # if set_wait is called without a param then the second to last
- # wait will be used.
+ # Set implicit wait. Default to @default_wait.
#
# ```ruby`
# set_wait 2
- # set_wait 3
- # set_wait # 2
+ # set_wait # @default_wait
#
# ````
#
# @param timeout [Integer] the timeout in seconds
# @return [void]
def set_wait(timeout = nil)
- if timeout.nil?
- # Appium::Logger.info "timeout = @default_wait = @last_wait"
- # Appium::Logger.info "timeout = @default_wait = #{@last_waits}"
- timeout = @default_wait = @last_waits.first
- else
- @default_wait = timeout
- # Appium::Logger.info "last waits before: #{@last_waits}"
- @last_waits = [@last_waits.last, @default_wait]
- # Appium::Logger.info "last waits after: #{@last_waits}"
- end
-
+ timeout = @default_wait if timeout.nil?
@driver.manage.timeouts.implicit_wait = timeout
end
# Returns existence of element.
#
@@ -695,9 +680,18 @@
# quit and exit are reserved by Pry.
# @return [void]
def x
driver_quit
exit # exit pry
+ end
+
+ private
+
+ # If "automationName" is set only server side, this method set "automationName" attribute into @automation_name.
+ # Since @automation_name is set only client side before start_driver is called.
+ def set_automation_name_if_nil
+ return unless @automation_name.nil?
+ @automation_name = @driver.capabilities['automationName']
end
end # class Driver
end # module Appium
# Paging in Pry is annoying :q required to exit.