yaml文件
platformName: Android
platformVersion: 4.4.2
deviceName: 127.0.0.1:62001
appPackage: com.tal.kaoyan
appActivity: com.tal.kaoyan.ui.activity.SplashActivity
noReset: False
ip: 127.0.0.1
port: 4723
noSign: Ture
appname: kaoyan3.1.0.apk
caps文件
from selenium import webdriver
from appium import webdriver
import yaml
import logging
import logging.config
import os
def appium_disired():
with open('../config/kyb_caps.yaml', 'r', encoding='utf-8') as file:
data = yaml.load(file, Loader=yaml.FullLoader)
base_path = os.path.dirname(os.path.dirname(__file__))
app_path = os.path.join(base_path, 'app', data['appname'])
desired_caps = {}
desired_caps['platformName'] = data['platformName']
desired_caps['platformVersion'] = data['platformVersion']
desired_caps['deviceName'] = data['deviceName']
desired_caps['app'] = app_path
desired_caps['appPackage'] = data['appPackage']
desired_caps['appActivity'] = data['appActivity']
desired_caps['noSign'] = data['noSign']
desired_caps['noReset'] = data['noReset']
driver = webdriver.Remote('http://' + str(data['ip']) + ':' + str(data['port']) + '/wd/hub', desired_caps)
return driver
if __name__ == '__main__':
appium_disired()