Appium常见方法

desired_caps = {}

desired_caps'[platfromName'] = 'Android'    #设备信息

desired_caps['platformVersion'] = '4.4.2'   #手机版本

desired_caps['deviceName'] = '''  #adb devices

desired_caps['appPackage'] = '' #包名

desired_caps['appActivity'] = '' #启动activity

1  执行方法

driver = webdriver.Remote('http://127.0.0.1/wd/hub',desired_caps)

2 安装APK到手机

driver.install_app( app_path)

3  手机中移除APP

扫描二维码关注公众号,回复: 2718291 查看本文章

driver.remove_app(app_id)

4   判断APP是事已经存在

driver.is_app_installed(bundle_id)  #可以传入app包名

5   发送手机文件到手机

import base64

data = str(base64.b64encode(data.encode('utf-8')),'utf-8')

driver.push_file(path,data)  #path  手机设备上的路径 (sdcard/......) 

6  从手机中拉取文件

import base 64

data = driver.push_file(path)

print(str(base64.b64decode(data),'utf-8'))

7  获取屏幕内元素

driver.page_source

-----------------------------------------------------------------------------------------------------------

adb shell

adb shell dumpsys window windows | prep mFocusedApp            adb获取包名

adb -help

adb start-server

adb kill-server

adb devices

adb push ( path)发送文件到手机

adb pull(path)从手机拉文件

adb logcat | prep 包名      查看log

adb install apk包名

adb uninstall 包名

猜你喜欢

转载自blog.csdn.net/dubo_csdn/article/details/81556654