Appium's new 2.0 brand new cross-platform ecology, version features early experience!

About Appium V2

The Appium V2 beta version will be released in 2021. Starting from January 1, 2022, the Appium core team will no longer maintain the Appium 1.x version. All recently officially released platform drivers (such as UIAutomator on the Android platform, XCUITest on the IOS platform ) is no longer compatible with Appium 1.x and needs to be based on Appium V2.

Let's take a look at the changes in Appium V2 compared to Appium 1.x

If you want to learn interface automation testing, here I recommend a set of videos for you. This video can be said to be the number one interface automation testing tutorial on the entire network at station B. At the same time, the number of online users has reached 1,000, and there are notes to collect and use. Technical exchanges of various masters: 798478386    

[Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (the latest version of actual combat)_哔哩哔哩_bilibili [Updated] The most detailed collection of practical tutorials for automated testing of Python interfaces taught by station B (actual combat) The latest version) has a total of 200 videos, including: 1. [Interface Automation] The current market situation of software testing and the ability standards of testers. , 2. [Interface Automation] Fully skilled in the Requests library and the underlying method call logic, 3. [Interface Automation] interface automation combat and the application of regular expressions and JsonPath extractors, etc. For more exciting videos, please pay attention to the UP account. https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337&vd_source=488d25e59e6c5b111f7a1a1a16ecbe9a

Changes about Appium V2

Separate the platform driver

In the Appium V2 version, the driver and Appium Server are separated, and the driver can be installed and upgraded separately, such as UIAutomator on the Android platform, XCUITest on the IOS platform, etc.

Introducing the plug-in ecology
Appium V2 transfers some non-core component functions to the plug-in, and can expand more new functions through the plug-in mode. For example, through the official images plug-in, image recognition can be used to locate elements, using third-party The plugin appium-device-farm can centrally manage devices

·Strictly follow the W3C protocol
Similar to the W3C protocol introduced in Selenium 4, Appium V2 strictly follows the W3C protocol. To fill in the capabilities when writing test scripts in Appium V2, you need to specify the appium: prefix, for example:

{    "platformName": "Android",
   "appium:automationName": "uiautomator2",
   "appium:deviceName": "emulator-5554",
   "appium:appPackage": "com.lemon.lemonban",
   "appium:appActivity": "com.lemon.lemonban.activity.WelcomeActivity"
}

Specifically which are the capabilities in the standard W3C protocol, you can view the document https://www.w3.org/TR/webdriver/#capabilities

Where platformName is a capability in the standard W3C protocol, no need to add a prefix

Capabilities in non-standard W3C protocols need to add appium: prefix

Preparations before use:

The Appium V2 version currently needs to be installed based on the nodejs environment, and there are corresponding requirements for the nodejs version:

Node.js version in the SemVer range ^14.17.0 || ^16.13.0 || >=18.0.0

NPM version >= 8 (NPM is usually bundled with Node.js, but can be upgraded independently)

Here we choose to download the latest version directly from the official website of nodejs https://nodejs.org/en:

picture

 Step1: Install Appium V2

npm install -g appium@next

At present, Appium V2 has not been officially released yet, and it still belongs to the rc (Release Candidate-release candidate version) version. It must be installed with the appium@next parameter during installation. When Appium V2 is officially released, we can use the appium parameter to install it.

After the installation is complete, check the appium version number:

appium -v

The output is:

2.0.0-rc.3

After Appium V2 is installed, you can expand and install various platform drivers and plug-ins through the Appium Extension CLI (Appium Extension Command Line) mode.

Step2: Install Appium driver

Taking the Android platform as an example, install the UIAutomator2 driver:

appium driver install uiautomator2  //Appium扩展命令行模式

After the installation is complete, you can view the installed drivers:

appium driver list

The output is:

picture

 Step3: Start Appium Server

Use the appium command to start:

picture

 Appium will start on port 4723 by default, and will load the installed driver locally when starting.

Step4: Install the Appium client library

Select the corresponding Appium client library for the programming language. For example, Python corresponds to Appium-Python-Client, which can be installed through pip; Java corresponds to Java-client, which can be installed through Maven or Gradle.

It should be noted here that if the previous project used related libraries, it needs to be upgraded to adapt to the latest Appium V2.

Step5: Write test scripts

Here is python as an example:

from appium import webdriver

caps = {
    "platformName": "Android",
    "automationName": "uiautomator2",
    "deviceName": 'emulator-5554',
    "appPackage": "com.lemon.lemonban",
    "appActivity": "com.lemon.lemonban.activity.WelcomeActivity",
    "noReset": True
}
appium_server_url = 'http://127.0.0.1:4723'
driver = webdriver.Remote(appium_server_url, caps)

It should be noted that the access address of Appium Server in version 1.x is: http://127.0.0.1/wd/hub, but the suffix /wd/hub is not needed in version V2. If you still use the previous address Access will appear 404.

Guess you like

Origin blog.csdn.net/m0_73409141/article/details/131773508