程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

App automated testing appium tutorial 3 - appium basic commands (Python)

編輯:Python

app Automated testing tutorial III ——appium Basic commands (python)

  • hello appium
  • Basic operation API

Teaching video reference b Station courses , This article is a learning record
( Free wool , It's time to collect , Bobbins ~)
Zero foundation entry mobile automation test ——Appium Frame video ( Black horse programmer ) Broadcast address

hello appium

  1. Software preparation : open appium+pycharm+mumu Simulator
    See... For the environment :app One of the automated test tutorials —— Environment building
  2. Connecting device :

open cmd, Input :adb connect 127.0.0.1:7555
Input :adb devices
Show :List of devices attached;127.0.0.1:7555 device The device is successfully connected

  1. Get package name / Interface name
    open mumu browser - equipment

Input :adb shell dumpsys window | findstr mCurrentFocus

  1. Start any application ( Routine is set for startup ,5s after , close )
// An highlighted block
from appium import webdriver
import time
desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0.1'//mumu Simulator - Set up - About tablets -Android edition 
desired_caps['deviceName'] = '127.0.0.1:7555'// Device number 
desired_caps['appPackage'] = 'com.android.settings'// Package name 
desired_caps['appActivity'] = 'com.android.settings.Settings'// Interface name 
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)//4723 by appium Set the port number 
time.sleep(5)
driver.quit()

Basic operation API

  1. Start other app
    Want an app to jump to another app , For example, after placing an order through the takeout platform, it will jump to the payment application

driver.start_activity(“com.android.gallery3d”, “com.android.gallery3d.app.GalleryActivity”)

  1. Get the package name and interface name

driver.current_package
driver.current_activity

  1. close app And drive objects

driver.close_app() # Back to the table ,driver still
driver.quit() # immediate withdrawal driver

  1. load and unload app
  • install

driver.install_app(app_path)

  • uninstall

driver.remove_app(“ Package name ”)

  • Determine whether to install

if driver.is_app_installed()

  1. Put the app in the background , Open it again ( Hot start )
  • Wait for a certain time to reopen

driver.background_app(seconds)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved