Two. First automated demo, open app-how to get package name and activity. (Real machine)

Source: Internet
Author: User
Tags appium

Once the environment has been configured successfully, we are ready for the first automated test. You do not need to install an Android emulator to use a real machine. Take a simple open app as an example.

First, get the package name and activtity

to launch an app, we need to know its platform, version number, package name, activity and other information, of which two are more difficult to find is the package name and Activtiy, the other directly on the phone or with itools can see .

1 in the previously configured Android SDK folder, locate sdkmanager.exe and start, tick a version of Build-tools and download it.

2) After successful download, locate Appt.exe and add this path to the environment variable-system variable-path:

3) Enter AAPT in the cmd command to test if the configuration is successful

4) The APK to be tested is placed in a folder, such as D:/test, in cmd input command: AAPT dump badging D:\test\xx.apk. Take tingshu.apk as an example:

Second, write a Python script. (I'm using Pycharm.)

From Appium import Webdriver  
Import Time #引用


desired_caps[' platformname ' = ' Android ' #所测平台
desired_caps[' platformversion '] = ' 6.0.1 ' #所测设备的系统版本号
desired_caps[' devicename '] = ' vivo_y66 ' #设备名称
desired_caps[' apppackage '] = ' Bubei.tingshu ' #包名
desired_caps[' appactivity '] = ' bubei.tingshu.listen.guide.ui.activity.LOGOActivity ' #activity
desired_caps[' noreset ') = True #不需要卸载重装app
Driver = Webdriver. Remote (' Http://127.0.0.1:4723/wd/hub ', desired_caps) #启动app
Time.sleep (5) #停留5秒
Driver.quit () #退出

Three. Start the Appiun service (Appium-desktop,appiun-server has not been updated since 2015)
1) Click on the icon to start, set host and port. (The default 127.0.0.1, 4723, you can also set the local address, this address is consistent with the address in the above script, research and update later)

2) Start successfully, click the button in the upper right corner to stop the service.

Iv. connect the mobile phone to the computer, enter the adb shell in CMD, and confirm the connection is successful.

After the link succeeds, run the corresponding script in Pycharm and we can see that the phone is executed by script.

(When first executed, the phone will pop up if you want to install appium-seeting ...) There is also a unlock pop-up window, click through on the line. )












Two. First automated demo, open app-how to get package name and activity. (Real machine)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.