Method: Appium::Core::Driver.for
- Defined in:
- lib/appium_lib_core/driver.rb
.for(opts = {}) ⇒ Driver
Creates a new driver and extend particular methods
Examples:
# format 1
@core = Appium::Core.for caps: {...}, appium_lib: {...}
# format 2. 'capabilities:' is also available instead of 'caps:'.
@core = Appium::Core.for url: "http://127.0.0.1:8080/wd/hub", capabilities: {...}, appium_lib: {...}
require 'rubygems'
require 'appium_lib_core'
# Start iOS driver
opts = {
caps: {
platformName: :ios,
platformVersion: '11.0',
deviceName: 'iPhone Simulator',
automationName: 'XCUITest',
app: '/path/to/MyiOS.app'
},
appium_lib: {
port: 8080,
wait: 0,
wait_timeout: 20,
wait_interval: 0.3,
listener: nil,
}
}
@core = Appium::Core.for(opts) # create a core driver with 'opts' and extend methods into 'self'
@core.start_driver # Connect to 'http://127.0.0.1:8080/wd/hub' because of 'port: 8080'
# Start iOS driver with .zip file over HTTP
# 'capabilities:' is also available instead of 'caps:'. Either is fine.
opts = {
capabilities: {
platformName: :ios,
platformVersion: '11.0',
deviceName: 'iPhone Simulator',
automationName: 'XCUITest',
app: 'http://example.com/path/to/MyiOS.app.zip'
},
appium_lib: {
server_url: 'http://custom-host:8080/wd/hub.com',
wait: 0,
wait_timeout: 20,
wait_interval: 0.3,
listener: nil,
}
}
@core = Appium::Core.for(opts)
@core.start_driver # Connect to 'http://custom-host:8080/wd/hub.com'
# Start iOS driver as another format. 'url' is available like below
opts = {
url: "http://custom-host:8080/wd/hub.com",
capabilities: {
platformName: :ios,
platformVersion: '11.0',
deviceName: 'iPhone Simulator',
automationName: 'XCUITest',
app: '/path/to/MyiOS.app'
},
appium_lib: {
wait: 0,
wait_timeout: 20,
wait_interval: 0.3,
listener: nil,
}
}
@core = Appium::Core.for(opts) # create a core driver with 'opts' and extend methods into 'self'
@core.start_driver # start driver with 'url'. Connect to 'http://custom-host:8080/wd/hub.com'
# With a custom listener
class CustomListener < ::Selenium::WebDriver::Support::AbstractEventListener
// something
end
capabilities: {
platformName: :ios,
platformVersion: '11.0',
deviceName: 'iPhone Simulator',
automationName: 'XCUITest',
app: '/path/to/MyiOS.app'
},
appium_lib: {
listener: CustomListener.new,
}
@core = Appium::Core.for capabilities: capabilities, appium_lib: appium_lib
@core.start_driver
Parameters:
-
opts
(Hash)
(defaults to: {})
—
A options include capabilities for the Appium Server and for the client.
Options Hash (opts):
-
:caps
(Hash)
—
Appium capabilities.
-
:capabilities
(Hash)
—
The same as :caps. This param is for compatibility with Selenium WebDriver format
-
:appium_lib
(Appium::Core::Options)
—
Capabilities affect only ruby client
-
:url
(String)
—
The same as :custom_url in :appium_lib. This param is for compatibility with Selenium WebDriver format
Returns:
- (Driver)
283 284 285 |
# File 'lib/appium_lib_core/driver.rb', line 283 def self.for(opts = {}) new.setup_for_new_session(opts) end |