Appium+python Automation 46-install app three ways

Source: Internet
Author: User
Tags appium

ADB installation

1. Before the app is automated, how do you install the app on your phone on your phone with the app you want to test first? You can enter the ADB command in CMD before running the automation code, and install the PC app on the phone

ADB install [apk on the absolute path on the computer]

2. You can also install the app in Python with the ADB command, which is implemented as follows:

# coding:utf-8import os# 安装app,为了方便,把app放到当前脚本同一目录os.system("adb install baidu.apk")

Appium Local Installation

1.appium can also be implemented to automatically install the app, under the project to build a separate app folder, to install the app to put in this folder

2. Build a case folder under the project and get the absolute path of the app when writing the use case

3. In order to obtain a convenient path, you can write a function to obtain, so that convenient to call

4. Further optimization of the code, with a more concise lambda function, function equivalent to the previous step

 #   Coding:utf-8  import   OS  #   Gets the root directory path of the project  p = Os.path.abspath (Os.path.join (Os.path.dirname (Os.path.realpath ( __file__ ),  "  ..  "  print   (p ) AppPath  = lambda  x:os.path.join (p,  "  app   "  , x)  print  (AppPath ( " baidu.apk  " )) 

5. Run the code to install the app under the specified folder

#Coding:utf-8 fromAppiumImportWebdriverImportOS#get the root directory path of the projectp = Os.path.abspath (Os.path.join (Os.path.dirname (Os.path.realpath (__file__)),".."))#Get app PathAppPath =LambdaX:os.path.join (P,"app", X)Print(AppPath ("baidu.apk")) Desired_caps= {                'PlatformName':'Android',                'devicename':'127.0.0.1:62001',                'platformversion':'4.4.2',                'app': AppPath ("baidu.apk"),                'Apppackage':'com.baidu.yuedu',                'appactivity':'com.baidu.yuedu.splash.SplashActivity',                'NoReset':'true',}driver= Webdriver. Remote ('Http://127.0.0.1:4723/wd/hub', Desired_caps)
Appium Online Installation

1. If there is no local app pack, an online installation is also possible. such as the test package after the upload to a specified, through this can also be installed

2. Baidu to read the app as a case, Baidu search: Baidu reading app, from the download page to get to the app

http://p.gdown.baidu.com/ B8d3f4be0e333cca250c2d3663bd2ba59f87740a58b4288dd0725134e7f455721f254aeb5c678ff9e6aa0d90b7322b1b06c5f3239bd7b726d2b0f2ac1 87f7c95e08cf4ef572d854a546c1814c9ad9101c58f29b5df2eeb11e751cff1d1a9d6d1e74aab7e8d53a9039a3c5cbea8e461ecb3348cd38123bebedf 6a9976c2fa7f1f1df6a6543c6d73124796e97a34cca9792f10878c878d124be5e1582911aea7870e909130f73adfac

3. Simply change the local address on the back of the app parameter to the online address.

"App": "App download online address"

4. Code reference:

#Coding:utf-8 fromAppiumImportWebdriverImportOsappurl="http://p.gdown.baidu.com/ B8d3f4be0e333cca250c2d3663bd2ba59f87740a58b4288dd0725134e7f455721f254aeb5c678ff9e6aa0d90b7322b1b06c5f3239bd7b726d2b0f2ac1 87f7c95e08cf4ef572d854a546c1814c9ad9101c58f29b5df2eeb11e751cff1d1a9d6d1e74aab7e8d53a9039a3c5cbea8e461ecb3348cd38123bebedf 6A9976C2FA7F1F1DF6A6543C6D73124796E97A34CCA9792F10878C878D124BE5E1582911AEA7870E909130F73ADFAC"Desired_caps= {                'PlatformName':'Android',                'devicename':'127.0.0.1:62001',                'platformversion':'4.4.2',                'app': AppUrl,'Apppackage':'com.baidu.yuedu',                'appactivity':'com.baidu.yuedu.splash.SplashActivity',                'NoReset':'true',}driver= Webdriver. Remote ('Http://127.0.0.1:4723/wd/hub', Desired_caps)

Appium+python Automation 46-install app three ways

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.