当前位置:网站首页>How to set appium script startup parameters
How to set appium script startup parameters
2022-07-24 20:23:00 【Zeze said test】
One 、 Confirm environment
Automated testing involves mobile phones 、 Computers and Appium Multi terminal interaction such as services , Before the official start , First of all, we need to confirm whether the environment is installed correctly :
- Connect your phone or turn on the simulator
- adb devices Make sure the phone is recognized
- start-up Appium service , And set the port
- function Python Script
If not installed appium Please refer to :Appium Environment construction nanny level tutorial
Two 、 To write Appium The startup script
Appium It is an automated testing framework that supports multiple platforms , start-up Appium The program needs to provide platformName Parameters , Indicate which operating system's automation engine needs to be used :
from appium.webdriver import Remote
caps = dict(platformName="Android")
driver = Remote(desired_capabilities=caps)
Open mobile phone , If you need to access specific App, take App The installation package path of is also placed in caps in , If you don't pass app Parameters , The home page of the device is opened by default .
caps = dict(platformName="Android",
app="/path/iBiliPlayer-bilibili.apk")
It is also possible to connect multiple mobile phones to the computer , If there are multiple phones , You need to specify the mobile device you want to operate , Use udid Parameters , The equipment number can be entered adb devices obtain . Usually , To a certain app Conduct automated tests , These three startup parameters are the most common .
caps = dict(platformName="Android",
app="/path/iBiliPlayer-bilibili.apk",
udid='emulator-5554')
When the data is ready , We can go directly to Appium Provided Remote class , Connect the corresponding app. After the operation , adopt quit Method to exit the entire session .
Remember that quit, Otherwise, when locating elements later , There may be an error that the source code of the page cannot be obtained .
from appium.webdriver import Remote
file = '/path/iBiliPlayer-bilibili.apk'
caps = dict(platformName="Android",
app=file,
udid='emulator-5554')
driver = Remote(desired_capabilities=caps)
driver.quit()
3、 ... and 、 Start by package name App
Usually ,Appium Can pass apk To directly operate the specified app. But it's inconvenient to get apk file , And our mobile phones have been installed with... To be tested app, So you can go through app The package name to start .
from appium.webdriver import Remote
caps = {
"platformName": "Android",
"udid": "emulator-5554",
"appPackage": "com.bilibili.app.blue",
"appActivity": "tv.danmaku.bili.ui.splash.SplashActivity"
}
driver = Remote(desired_capabilities=caps)
driver.quit()
Four 、 How to get App Package name and Activity name
You can get the startup directly through the following command app Of appPackage Parameters and appActivity Parameters ,
adb logcat | findStr -i displayed
After typing the command , Click manually to enter app, It can display which pages the phone has recently opened , The most recently opened page will be displayed at the bottom , So we get the required parameters .

Common startup parameters
Appium There are many startup parameters , It can be in the official Desired Capbility View in . Only platformName It is required. , Others are optional .
Common startup parameters :
- platformName Mandatory
- deviceName / udid Mandatory
- app The installation path
- appActivity and appPackage,
- platformVersion Optional , If the version does not match, an error will be reported
- noReset No reset , True
- automationName
- browserName, Direct measurement web use , Chrome
- autoWebview, Boot into the webview Pattern
- chromedriverExecutable
- chromedriverExecutableDir
- unicodeKeyboard
- resetKeyboard
- autoGrantPermissions
5、 ... and 、 A complete automated script
Through a complete script to illustrate .
1、 Connect the phone , start-up app
2、 Element localization , Perform the operation
3、 Exit procedure
from appium.webdriver import Remote
caps = {
"platformName": "Android",
"udid": "emulator-5554",
"appPackage": "com.bilibili.app.blue",
"appActivity": "tv.danmaku.bili.ui.splash.SplashActivity"
}
driver = Remote(desired_capabilities=caps,
command_executor = 'http://127.0.0.1:4723/wd/hub')
driver.implicitly_wait(10)
driver.find_element('id', 'com.bilibili.app.blue:id/agree').click()
driver.quit()
The end of this paper , If it's not fun , I also sorted out the complete notes from the introduction to advanced software testing , You can click to view :
What does software testing need to learn ?
The contents that have been updated include Selenium Web side web automated testing :
One 、 Why Selenium Do automated tests
Two 、Selenium chromedriver Installation tutorial and quick use
Four 、Selenium How elements are positioned
5、 ... and 、Selenium The way to wait
6、 ... and 、Selenium Scrolling pages
7、 ... and 、Selenium How to use POM Hierarchical mode
8、 ... and 、Selenium Keyword driven automated test framework
Appium Mobile App automated testing
One 、Appium Environment construction nanny level tutorial
Two 、Appium Get started quickly in five minutes
3、 ... and 、Appium How to locate elements
Four 、Appium The core API operation
5、 ... and 、Appium Get and click coordinates
6、 ... and 、Appium Zoom in and out of the picture
7、 ... and 、Appium H5 How to test the page
8、 ... and 、Appium 2.0 Release , How to upgrade
Nine 、Appium How to do concurrent testing
Come in and have a look : Software testing and automated testing learning roadmap
边栏推荐
- Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
- vlan技术
- Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
- VLAN Technology
- Working principle of envy of istio I
- How does starknet change the L2 landscape?
- Leetcode 300 longest increasing subsequence (greedy + binary search for the first element subscript smaller than nums[i]), leetcode 200 island number (deep search), leetcode 494 target sum (DFS backtr
- C form application treeview control use
- Valdo2021 - vascular space segmentation in vascular disease detection challenge (2)
- Wechat stores build order pages and automatically grab tickets
猜你喜欢

vlan技术

Bypass using the upper limit of the maximum number of regular backtracking

Richview table table alignment
![Microservice architecture | service monitoring and isolation - [sentinel] TBC](/img/28/8ca90e9dbd492688e50446f55959ff.png)
Microservice architecture | service monitoring and isolation - [sentinel] TBC

The difference between map and flatmap in stream

Connect the smart WiFi remote control in the home assistant
![[training Day9] maze [line segment tree]](/img/56/e8458245fe564821740ab94ece37a4.png)
[training Day9] maze [line segment tree]

The U.S. economy continues to be weak, and Microsoft has frozen recruitment: the cloud business and security software departments have become the hardest hit
![[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]](/img/75/5eca7f63758802ecf86a90a1bbdeaf.png)
[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]

Markdown to PDF API data interface
随机推荐
[msp430g2553] graphical development notes (1) configuration environment
Is the incremental update of SQL Server database identified according to the where clause? Can't do stream update? Each table should
Thinking of @requestbody caused by hi and hello requests
Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
Usage and introduction of MySQL binlog
[training Day9] maze [line segment tree]
Framework API online viewing source code
从码农转型大音乐家,你只差这些音乐处理工具
【LeetCode】1184. 公交站间的距离
[training Day8] series [matrix multiplication]
Valdo2021 - vascular space segmentation in vascular disease detection challenge (I)
存储类别
English translation Chinese common dirty words
The U.S. economy continues to be weak, and Microsoft has frozen recruitment: the cloud business and security software departments have become the hardest hit
Do you want to enroll in a training class or study by yourself?
Connect the smart WiFi remote control in the home assistant
Istio一之Envoy工作原理
Software testing interview tips | if you don't receive the offer, I'll wash my hair upside down
Rhodamine B labeled PNA | rhodamine b-pna | biotin modified PNA | biotin modified PNA | specification information
870. Approximate number