当前位置:网站首页>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 connect
Link devices ,
Or byadb devices
The 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
边栏推荐
- 【Rust 笔记】17-并发(上)
- Introduction and experience of wazuh open source host security solution
- 中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章
- RGB LED infinite mirror controlled by Arduino
- Sword finger offer 05 Replace spaces
- Little known skills of Task Manager
- On the characteristics of technology entrepreneurs from Dijkstra's Turing Award speech
- 可变电阻器概述——结构、工作和不同应用
- [jailhouse article] jailhouse hypervisor
- 7. Processing the input of multidimensional features
猜你喜欢
Scope of inline symbol
The connection and solution between the shortest Hamilton path and the traveling salesman problem
Sword finger offer 09 Implementing queues with two stacks
【Jailhouse 文章】Jailhouse Hypervisor
Little known skills of Task Manager
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
Full Permutation Code (recursive writing)
Dynamic planning solution ideas and summary (30000 words)
EOJ 2021.10 E. XOR tree
Solution to game 10 of the personal field
随机推荐
2022年貴州省職業院校技能大賽中職組網絡安全賽項規程
Appium基础 — 使用Appium的第一个Demo
剑指 Offer II 058:日程表
【Rust 笔记】14-集合(上)
智慧工地“水电能耗在线监测系统”
实时时钟 (RTC)
Cluster script of data warehouse project
In this indifferent world, light crying
1041 Be Unique
Codeforces Round #716 (Div. 2) D. Cut and Stick
Bit mask of bit operation
【Jailhouse 文章】Look Mum, no VM Exits
API related to TCP connection
The number of enclaves
数据可视化图表总结(一)
Introduction to LVS [unfinished (semi-finished products)]
CF1637E Best Pair
6. Logistic model
js快速将json数据转换为url参数
【Rust 笔记】15-字符串与文本(下)