Appium-Create

2021/4/9 10:29:07

本文主要是介绍Appium-Create,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录

          • Create New Session
          • Example Usage
          • Description
          • Support
            • Appium Server
            • Appium Clients
          • HTTP API Specifications
            • Endpoint
            • URL Parameters
            • JSON Parameters
            • Response

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

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

  • JSONWP Spec所需的功能具有比所需功能更高的优先级,必须为要创建的会话进行设置
  • W3C Spec能力.alwaysMatch必须为要创建的会话设置;功能.firstMatch必须至少匹配一个(将使用第一个匹配的)
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-Create的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程