当前位置:网站首页>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
边栏推荐
- Codeforces Round #715 (Div. 2) D. Binary Literature
- leetcode-6110:网格图中递增路径的数目
- Introduction and experience of wazuh open source host security solution
- CF1637E Best Pair
- 【Rust 笔记】16-输入与输出(上)
- Annotation and reflection
- 1039 Course List for Student
- Sword finger offer 05 Replace spaces
- Bit mask of bit operation
- Daily question 2006 Number of pairs whose absolute value of difference is k
猜你喜欢
On the characteristics of technology entrepreneurs from Dijkstra's Turing Award speech
leetcode-6110:网格图中递增路径的数目
Wazuh開源主機安全解决方案的簡介與使用體驗
实时时钟 (RTC)
【Jailhouse 文章】Jailhouse Hypervisor
Sword finger offer 53 - I. find the number I in the sorted array
【Jailhouse 文章】Look Mum, no VM Exits
Sword finger offer 09 Implementing queues with two stacks
6. Logistic model
网络工程师考核的一些常见的问题:WLAN、BGP、交换机
随机推荐
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
做 SQL 性能优化真是让人干瞪眼
QT判断界面当前点击的按钮和当前鼠标坐标
Codeforces round 712 (Div. 2) d. 3-coloring (construction)
【Rust 笔记】13-迭代器(下)
Time complexity and space complexity
Brief introduction to tcp/ip protocol stack
leetcode-1200:最小绝对差
redis发布订阅命令行实现
个人开发的渗透测试工具Satania v1.2更新
2022年貴州省職業院校技能大賽中職組網絡安全賽項規程
Sword finger offer 05 Replace spaces
【Rust 笔记】13-迭代器(中)
2022 pole technology communication arm virtual hardware accelerates the development of Internet of things software
Simply sort out the types of sockets
CPU内核和逻辑处理器的区别
1039 Course List for Student
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
Transform optimization problems into decision-making problems
1039 Course List for Student