当前位置:网站首页>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
边栏推荐
- Binary search template
- leetcode-3:无重复字符的最长子串
- Flutter Web 硬件键盘监听
- 从Dijkstra的图灵奖演讲论科技创业者特点
- Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
- A reason that is easy to be ignored when the printer is offline
- Appium自动化测试基础 — Appium测试环境搭建总结
- redis发布订阅命令行实现
- QQ电脑版取消转义符输入表情
- Daily question 2006 Number of pairs whose absolute value of difference is k
猜你喜欢
CF1637E Best Pair
【Jailhouse 文章】Jailhouse Hypervisor
从Dijkstra的图灵奖演讲论科技创业者特点
[jailhouse article] look mum, no VM exits
Appium自动化测试基础 — Appium测试环境搭建总结
实时时钟 (RTC)
[jailhouse article] jailhouse hypervisor
Wazuh開源主機安全解决方案的簡介與使用體驗
On the characteristics of technology entrepreneurs from Dijkstra's Turing Award speech
LeetCode 0108.将有序数组转换为二叉搜索树 - 数组中值为根,中值左右分别为左右子树
随机推荐
leetcode-6109:知道秘密的人数
Daily question 1342 Number of operations to change the number to 0
常见的最优化方法
Binary search template
Sword finger offer 35 Replication of complex linked list
ALU逻辑运算单元
可变电阻器概述——结构、工作和不同应用
实时时钟 (RTC)
Typical use cases for knapsacks, queues, and stacks
Maximum number of "balloons"
Codeforces Round #715 (Div. 2) D. Binary Literature
CF1637E Best Pair
1996. number of weak characters in the game
js快速将json数据转换为url参数
shared_ Repeated release heap object of PTR hidden danger
RGB LED infinite mirror controlled by Arduino
2017 USP Try-outs C. Coprimes
leetcode-9:回文数
[practical skills] technical management of managers with non-technical background
网络工程师考核的一些常见的问题:WLAN、BGP、交换机