当前位置:网站首页>Appium foundation - use the first demo of appium
Appium foundation - use the first demo of appium
2022-07-05 06:03:00 【Test - Eight Precepts】
We use Python Language as the writing language of test script .
Before executing the script :
- Android The simulator or mobile phone is turned on .
- Make sure the computer and Android The device is linked .
That is to use ADB commandadb connectLink devices ,
Or byadb devicesThe command can view the device . - Turn on Appium service .
stay Python Development of IDE in (PyCharm) Write the following script in :
"""
1. Learning goals
master appium How to start the phone
2. Operation steps
1- explain : Explicit drive object ( Action object )
web Automated steps :
1. Specifies to launch the browser
2. Enter url
3. Continue with other operations ...
APP Automated steps :
First pass the following message :
System name : Android IOS
System version : Version number
Equipment name : adopt adb devices Command acquisition
APP Package name : Open which APP
APP Start name : Get into APP Which page
2- Import appium in webdriver
3- Add startup parameters
Equipment information
System name : Android IOS
System version : Version number
Equipment name : adb devices
APP Information
APP Package name : Open which APP
APP Start name : Get into APP Which page
4- start-up app
webdriver.Remote()
5- operation app
6- close app
3. demand
start-up Android Settings in the simulator APP
"""
# 1. Import appium
import time
from appium import webdriver
# 2. Add startup parameters
# Namely Desired capabilities, Is a dictionary type object .
desired_caps = {
"platformName": "Android", # System name
"platformVersion": "7.1.2", # System version
"deviceName": "127.0.0.1:21503", # Equipment name
"appPackage": "com.android.settings", # APP Package name
"appActivity": ".Settings" # APP Start name
}
"""
explain :
deviceName :
cmd Go to the command line terminal
Input adb connect 127.0.0.1:21503 Link carefree Simulator
Input adb devices Get device name
appPackage and appActivity obtain :
First, open the settings in the virtual machine
Enter the command adb shell dumpsys window windows | findstr mFocusedApp
stay u0 After that is the package name and startup name com.android.settings/.Settings
"""
"""
Tips :
platformName Field Android and android It can be in both case .
deviceName Field , In the test Android The phone , You can write as you like , such as 123
because deviceName The field is for IOS Systematic ,
about Android System , This field must have , But the content can be written at will , And cannot be empty .
platformVersion You can write two digits in the field , Be able to run .
"""
# 3. start-up APP
# Declare the mobile phone driver object ( Instantiation webdriver)
# The first parameter is zero appium Address of service , Need to start the appium service .
# The second parameter is Desired capabilities object
# Let's just pass in these two parameters first .
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
# http://127.0.0.1:4723/wd/hub in /wd/hub This is fixed , There has to be , Required .
# The above step has put app It's on .
# 4. operation APP
# Not first app Do anything .
# 5. close APP
time.sleep(5)
driver.quit()
Tips :
function appium Code considerations :
1. Guaranteed equipment ( mobile phone ) Successfully connected to the computer
Is the use of adb connect The command links the device
perhaps adb devices You can view the device name
2. function appium server( The service is started )
3. Just execute the test code .
Be careful : If it's the first run Appium Script , You will install a device called Appium Settings Of App.

Finally, let's take a look Appium What does the service log say about , as follows :
[Appium] Welcome to Appium v1.13.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
# One session
[HTTP] --> POST /wd/hub/session
# Pass in Desired capabilities Dictionary type object
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:platformVersion":"7.1.2","appium:deviceName":"127.0.0.1:21503","appium:appPackage":"com.android.settings","appium:appActivity":".Settings"}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"7.1.2","deviceName":"127.0.0.1:21503","appPackage":"com.android.settings","appActivity":".Settings"}}
# start-up AppiumDriver, Create an echo
[W3C] Calling AppiumDriver.createSession() with args:
... Omit some information ...
# Then start some ADB command
[ADB] Found 2 'build-tools' folders under 'F:\DevInstall\envs\android-sdk-windows' (newest first):
[ADB] F:/DevInstall/envs/android-sdk-windows/build-tools/29.0.3
... Omit some information ...
[BaseDriver] Event 'newSessionStarted' logged at 1605778307025 (17:31:47 GMT+0800 ( China standard time ))
# 6d2f52a7-f71e-4842-98e9-22aff59a4b38 by sessionID
[W3C (6d2f52a7)] Cached the protocol value 'W3C' for the new session 6d2f52a7-f71e-4842-98e9-22aff59a4b38
... Omit some information ...
[BaseDriver] Event 'quitSessionFinished' logged at 1605778313510 (17:31:53 GMT+0800 ( China standard time ))
[W3C (6d2f52a7)] Received response: null
[W3C (6d2f52a7)] But deleting session, so not returning
[W3C (6d2f52a7)] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/6d2f52a7-f71e-4842-98e9-22aff59a4b38 200 1469 ms - 14
[HTTP] Tips :
- The suffix for Android apps is
.apk, yes AndroidPackage Abbreviation . - IOS Installation package
.ipa, install ios Test version , need Ios Development will iPhone Mobile phone UUID Add the number to the developer project .
a key : Supporting learning materials and video teaching
So here I have carefully prepared the detailed information of the above outline in The link below is as follows


边栏推荐
- 2017 USP Try-outs C. Coprimes
- CPU内核和逻辑处理器的区别
- Smart construction site "hydropower energy consumption online monitoring system"
- One question per day 1447 Simplest fraction
- 1.14 - 流水线
- Flutter Web 硬件键盘监听
- Implement a fixed capacity stack
- The connection and solution between the shortest Hamilton path and the traveling salesman problem
- Common optimization methods
- 2022 极术通讯-Arm 虚拟硬件加速物联网软件开发
猜你喜欢

Dichotomy, discretization, etc

Wazuh開源主機安全解决方案的簡介與使用體驗

Implement an iterative stack
![[practical skills] how to do a good job in technical training?](/img/a3/7a1564cd9eb564abfd716fef08a9e7.jpg)
[practical skills] how to do a good job in technical training?
![[practical skills] technical management of managers with non-technical background](/img/4d/1081c71df6ee2087359111baf7498a.png)
[practical skills] technical management of managers with non-technical background

全排列的代码 (递归写法)

【Jailhouse 文章】Jailhouse Hypervisor

Sword finger offer 04 Search in two-dimensional array

Appium自动化测试基础 — Appium测试环境搭建总结

Introduction and experience of wazuh open source host security solution
随机推荐
常见的最优化方法
Règlement sur la sécurité des réseaux dans les écoles professionnelles secondaires du concours de compétences des écoles professionnelles de la province de Guizhou en 2022
A reason that is easy to be ignored when the printer is offline
Brief introduction to tcp/ip protocol stack
[cloud native] record of feign custom configuration of microservices
CF1634 F. Fibonacci Additions
数据可视化图表总结(一)
中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章
[practical skills] how to do a good job in technical training?
Individual game 12
927. 三等分 模拟
QT判断界面当前点击的按钮和当前鼠标坐标
Introduction to convolutional neural network
One question per day 1765 The highest point in the map
打印机脱机时一种容易被忽略的原因
ALU逻辑运算单元
leetcode-1200:最小绝对差
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
CCPC Weihai 2021m eight hundred and ten thousand nine hundred and seventy-five
leetcode-556:下一个更大元素 III