在使用appium啟動(dòng)APP時(shí),需要通過webDriver訪問appium服務(wù):
def get_android_driver(self):
desired_caps = {
"platformName": "Android",
"automationName": "UiAutomator2",
"deviceName": device_name,
"platformVersion": "10.0", # 系統(tǒng)版本號(hào)
"appPackage": "cn.com.open.mooc", # 包名
"appActivity": "com.imooc.component.imoocmain.splash.MCSplashActivity", # 啟動(dòng)active頁(yè)
"noReset": "true" # 不用清除app數(shù)據(jù)
}
driver = webdriver.Remote("127.0.0.1:4723/wd/hub", desired_caps)
return driver
那么"127.0.0.1:4723/wd/hub"具體含義是什么呢?
首先 "127.0.0.1"是換回(loopback)地址,和localhost等價(jià)。
"4723"是端口號(hào),可以使用"netstat -ano"來查看目前被占用的端口號(hào)。
"wd" 可以理解為"WebDriver"的縮寫。
最后"hub"是指主(中心)節(jié)點(diǎn)。