该文档主讲如何远程机器,并经过远程的机器模拟器打开app,虚拟机远程到本机,调用mumu模拟器来运行app上的一系列操做;html
备注:在实际的项目中,我是把虚拟机当作客户端,本地当作服务器,从而在JENKINS上启动脚本任务后,虚拟机远程到本机,调用mumu模拟器来运行app上的一系列操做;python
5.设置【Remote Host】为你的本机IP地址,【Remote Port】与你上一步的设置一致此处为4723,添加Json Representationandroid
{web
"platformName": "Android",服务器
"deviceName": "127.0.0.1:7555",微信
"app": "E:\\APPNIUM\\apk\\weixin_1420.apk"session
}app
def open_app(self):
desired_caps = {}
desired_caps['platformName'] = 'Android' # 设备系统
desired_caps['automationName'] = 'appium' # 设备系统
desired_caps['deviceName'] = 'Netease MuMu' # 设备名称
remote_udid = os.environ.get('udid', '127.0.0.1:7555')#设置设备的udid
desired_caps['udid'] = remote_udid
desired_caps['appPackage'] = 'com.hd123.apos.ui.develop' # 测试app包名
desired_caps['appActivity'] = 'com.hd123.apos.ui.view.welcome.SplashActivity' # 测试appActivity
desired_caps['autoGrantPermissions'] = 'true'
desired_caps['noReset'] = 'true'
# driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) # 启动app
remote_address = os.environ.get('IP', 'http://localhost:4723/wd/hub')
driver = webdriver.Remote(remote_address, desired_caps) # 启动app
#点击取消按钮
by = (By.ID, 'com.hd123.apos.ui.develop:id/cancel_tv')
OperateWebElement.waitByAndClick(self, driver, 1000, by)
#点击确认,暂不注册按钮
loc_text = 'new UiSelector().text("确认,暂不注册")'
confirm_element = driver.find_element_by_android_uiautomator(loc_text)
OperateWebElement.waitElementAndClick(self, 1000, confirm_element)
return driver测试
执行的指令echo IP is $IPui
echo udid is $udid
PYTHONIOENCODING=utf-8 TEST_DEBUG=x IP=$IP udid=$udid python -m pytest test/apos -m "$label" -sv --junitxml=junit.xml --html=report.html --self-contained-html --alluredir=out