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 }) ⇒ Selenium::WebDriver

Attach to an existing session. The main usage of this method is to attach to an existing session for debugging. The generated driver instance has the capabilities which has the given automationName and platformName only since the W3C WebDriver spec does not provide an endpoint to get running session’s capabilities.

Examples:


new_driver = ::Appium::Core::Driver.attach_to(
  driver.session_id,  # The 'driver' has an existing session id
  url: 'http://127.0.0.1:4723', automation_name: 'UiAutomator2', platform_name: 'Android'
)
new_driver.page_source # for example

Parameters:

  • session_id (String)

    The session id to attach to.

  • url (String) (defaults to: nil)

    The WebDriver URL to attach to with the session_id.

  • automation_name (String) (defaults to: nil)

    The platform name to keep in the dummy capabilities

  • platform_name (String) (defaults to: nil)

    The automation name to keep in the dummy capabilities

Returns:

  • (Selenium::WebDriver)

    A new driver instance with the given session id.



307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/appium_lib_core/driver.rb', line 307

def self.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 }
)
  new.attach_to(
    session_id,
    automation_name: automation_name,
    platform_name: platform_name,
    url: url,
    http_client_ops: http_client_ops
  )
end