运行代码后,两台设备都会启动 APP,但是只有一台设备在执行用例,而且会执行两次。
appium -p 4723 -bp 4724
appium -p 4725 -bp 4726
def desired_caps(platformVersion, udid, deviceName ,port):
with open("../config/desired_caps.yaml", 'r', encoding='utf-8') as f:
data = yaml.load(f)
caps = dict()
caps['platformVersion'] = platformVersion
caps['udid'] = udid
caps['deviceName'] = deviceName
caps['platformName'] = data['platformName']
caps['appPackage'] = data['appPackage']
caps['appActivity'] = data['appActivity']
caps['unicodeKeyboard'] = data['unicodeKeyboard']
caps['resetKeyboard'] = data['resetKeyboard']
caps['automationName'] = data['automationName']
caps['noReset'] = data['noReset']
base_path = os.path.dirname(os.path.dirname(__file__))
file_path = os.path.join(base_path, 'app', 'kaoyan.apk')
caps['app'] = file_path
driver = webdriver.Remote('http://{}:{}/wd/hub'.format(data["ip"], port), caps)
driver.implicitly_wait(2)
usernameTF = 'com.XXX'
pwdTF = 'com.XXX'
loginBtn = 'com.XXX'
driver.find_element_by_id(usernameTF).send_keys("1231231231")
driver.find_element_by_id(pwdTF).send_keys("123123123")
driver.find_element_by_id(loginBtn).click()
if __name__ == '__main__':
_version = ["7.1.1", "6.0.1"]
_udid = ["ZX1G429WZM", "bbda9633"]
_name = ["Nexus 6", "Galaxy S5"]
desired_process = []
for i in range(2):
port = 4723 + i * 2
desired = multiprocessing.Process(target=desired_caps, args=(_version[i], _udid[i], _name[i], port))
desired_process.append(desired)
for process in desired_process:
process.start()
for process in desired_process:
process.join()
求大神帮忙,非常感谢!!!