該文檔主講如何遠程機器,並經過遠程的機器模擬器打開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