This documentation is deprecated. Please refer to the README in the Appium repository or Appium 2.0 documentation.
Edit this Doc Create New Session
Create a new session
Example Usage
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3");
desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
desiredCapabilities.setCapability(MobileCapabilityType.APP, "/path/to/ios/app.zip");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
IOSDriver driver = new IOSDriver(url, desiredCapabilities);
String sessionId = driver.getSessionId().toString();
desired_caps = {
'platformName': 'Android',
'platformVersion': '7.0',
'deviceName': 'Android Emulator',
'automationName': 'UiAutomator2',
'app': PATH('/path/to/app')
}
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
// webdriver.io example
# MJSONWP,
let options = { desiredCapabilities: {
platformName: 'Android',
platformVersion: '7.0',
automationName: 'UiAutomator2',
app: path.resolve('path', 'to', 'app.apk')
}};
# or W3C
options = { capabilities: {
platformName: 'Android',
platformVersion: '7.0',
'appium:automationName': 'UiAutomator2',
'appium:app': path.resolve('path', 'to', 'app.apk')
}};
const client = driver.newSession(options);
// wd example
let driver = await wd.promiseChainRemote({
host: '127.0.0.1',
port: 4723
});
let desiredCaps = {
platformName: 'Android',
platformVersion: '7.0',
deviceName: 'Android Emulator',
app: path.resolve('path', 'to', 'app.apk')
};
await driver.init(desiredCaps);
# ruby_lib example
APP_PATH = '../../path/to/app.app'
desired_caps = {
caps: {
platformName: 'iOS',
platformVersion: '10.2',
deviceName: 'iPhone 6',
app: APP_PATH,
automationName: "XCUITest"
}
}
Appium::Driver.new(desired_caps).start_driver
# ruby_lib_core example
::Appium::Core.for(desired_caps).start_driver
AppiumOptions capabilities = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1.1");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Device");
appiumOptions.AddAdditionalCapability("appPackage", "com.instagram.android");
appiumOptions.AddAdditionalCapability("appActivity", "com.instagram.android.activity.MainTabActivity");
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
Description
The server should attempt to create a session that most closely matches the desired and required capabilities.
- JSONWP Spec Required capabilities have higher priority than desired capabilities and must be set for the session to be created
- W3C Spec capabilities.alwaysMatch must be set for session to be created; capabilities.firstMatch must match at least one (the first one to match will be used)
Please do not forget to call delete command at the end of the session so that Appium could cleanup the downstream resources properly. Refusing to do so could corrupt the following session creation attempts or to break the stability of your tests in general.
Support
Appium Server
Platform | Driver | Platform Versions | Appium Version | Driver Version |
---|---|---|---|---|
iOS | XCUITest | 9.3+ | 1.6.0+ | All |
UIAutomation | 8.0 to 9.3 | All | All | |
Android | Espresso | ?+ | 1.9.0+ | All |
UiAutomator2 | ?+ | 1.6.0+ | All | |
UiAutomator | 4.3+ | All | All | |
Mac | Mac | ?+ | 1.6.4+ | All |
Windows | Windows | 10+ | 1.6.0+ | All |
Appium Clients
Language | Support | Documentation |
---|---|---|
Java | All | www.selenium.dev |
Python | All | selenium-python.readthedocs.io |
Javascript (WebdriverIO) | All | |
Javascript (WD) | All | github.com |
Ruby | All | www.rubydoc.info |
C# | All | github.com |
HTTP API Specifications
Endpoint
POST /session
URL Parameters
None
JSON Parameters
name | type | description |
---|---|---|
desiredCapabilities | object |
(JSONWP specification) Object describing session's desired capabilities |
requiredCapabilities | object |
(JSONWP specification) Object describing session's required capabilities that must be applied by remote end |
capabilities | object |
(W3C specification) object containing 'alwaysMatch' and 'firstMatch' properties |
capabilities.alwaysMatch | object |
The desired capabilities that the remote end must match |
capabilities.firstMatch | array<object> |
List of capabilities that the remote end tries to match. Matches the first in the list |
Response
An object describing the session's capabilities (object
)