其他分享
首页 > 其他分享> > Appium-Create

Appium-Create

作者:互联网

目录

Create New Session

Create a new session

Example Usage
JavaDesiredCapabilities 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();
Pythondesired_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)
Javascript// webdriver.io example
let options = { desiredCapabilities: {
platformName: 'Android',
platformVersion: '7.0',
automationName: 'UiAutomator2',
app: path.resolve('path','to', 'app.apk')}};
let 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# 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
C#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 driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
PHP
Description

服务器应尝试创建与所需功能最匹配的会话。

Support
Appium Server

与上篇一致

Appium Clients

与上篇一致

HTTP API Specifications
Endpoint

POST /session

URL Parameters

None

JSON Parameters
nametypedescription
desiredCapabilitiesobject(JSONWP specification) Object describing session’s desired capabilities
requiredCapabilitiesobject(JSONWP specification) Object describing session’s required capabilities that must be applied by remote end
capabilitiesobject(W3C specification) object containing ‘alwaysMatch’ and ‘firstMatch’ properties
capabilities.alwaysMatchobjectThe desired capabilities that the remote end must match
capabilities.firstMatcharray<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) //描述会话功能的对象(object)

标签:Appium,app,driver,desiredCapabilities,new,Android,path,Create
来源: https://blog.csdn.net/weixin_45576146/article/details/115523612