一 基础知识
二 实践
步骤:
1.新建yaml文件存储配置信息
2.py文件调用yaml文件里的配置信息
capability_yaml.yaml 代码:
platformName: Android
platformVersion: 5.1.1
deviceName: 127.0.0.1:62025
app: C:\Users\Administrator\Desktop\finance-googleplay-nonprodalpha-release.apk
appPackage: com.microsoft.amp.apps.bingfinance.nonprod
appWaitActivity: com.microsoft.amp.apps.bingfinance.activities.views.MainActivity
noRest: False
ip: 127.0.0.1
port: 4723
py文件代码:
'''
Created on 2019年1月23日
@author: Administrator
'''
#coding=utf-8
from selenium import webdriver
import yaml
file=open('capability_yaml.yaml','r')
data=yaml.load(file)
desired_caps = {}
desired_caps['platformName'] = data['platformName']
desired_caps['platformVersion'] = data['platformVersion']
desired_caps['deviceName'] = data['deviceName']
desired_caps['appPackage'] = data['appPackage']
desired_caps['appWaitActivity'] = data['appWaitActivity']
desired_caps['noRest'] = data['noRest']
driver = webdriver.Remote('http://'+str(data['ip'])+':'+str(data['port'])+'/wd/hub',desired_caps)
三 报错
1. raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4723): Max retries exceeded with url: /wd/hb/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000000003FAB518>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。',))
解决:appium 未启动导致,启动appium 重新运行
2. Message: The URL '/wd/hb/session' did not map to a valid resource
问题:'/ wd / hb / session'未映射到有效资源
解决:将'/ wd / hb / session'修改为'/ wd / hub / session'
网友评论