Method: Appium::Core::Driver#attach_to
- Defined in:
- lib/appium_lib_core/driver.rb
#attach_to(session_id, url: nil, automation_name: nil, platform_name: nil, http_client_ops: { http_client: nil, open_timeout: 999_999, read_timeout: 999_999 }) ⇒ Object
Attach to an existing session
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/appium_lib_core/driver.rb', line 440 def attach_to(session_id, url: nil, automation_name: nil, platform_name: nil, http_client_ops: { http_client: nil, open_timeout: 999_999, read_timeout: 999_999 }) raise ::Appium::Core::Error::ArgumentError, 'The :url must not be nil' if url.nil? raise ::Appium::Core::Error::ArgumentError, 'The :automation_name must not be nil' if automation_name.nil? raise ::Appium::Core::Error::ArgumentError, 'The :platform_name must not be nil' if platform_name.nil? @custom_url = url # use lowercase internally @automation_name = convert_downcase(automation_name) @device = convert_downcase(platform_name) extend_for(device: @device, automation_name: @automation_name) @http_client = get_http_client http_client: http_client_ops.delete(:http_client), open_timeout: http_client_ops.delete(:open_timeout), read_timeout: http_client_ops.delete(:read_timeout) # Note that 'enable_idempotency_header' works only a new session reqeust. The attach_to method skips # the new session request, this it does not needed. begin # included https://github.com/SeleniumHQ/selenium/blob/43f8b3f66e7e01124eff6a5805269ee441f65707/rb/lib/selenium/webdriver/remote/driver.rb#L29 @driver = ::Appium::Core::Base::Driver.new(http_client: @http_client, url: @custom_url, listener: @listener, existing_session_id: session_id, automation_name: automation_name, platform_name: platform_name) rescue Errno::ECONNREFUSED raise ::Appium::Core::Error::SessionNotCreatedError, "ERROR: Unable to connect to Appium. Is the server running on #{@custom_url}?" end @driver end |