threading 去分流用例数量
如果 1 台台手机跑是对的,一起跑就有错误信息了。
[MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8200
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: java.lang.IllegalThreadStateException: Thread already started
from appium import webdriver
import threading
import time
def test(udid, url):
desired_caps = {}
# 哪一种移动平台,iOS,Android...
desired_caps['platformName'] = 'Android'
# 平台的系统版本
desired_caps['platformVersion'] = '6.0'
# 设备的名称,可以通过adb devices查看
desired_caps['deviceName'] = 'MYV0215A08011601'
desired_caps['udid'] = udid
# 待测试的app的包名和appActivity名
desired_caps['appPackage'] = 'com.android.calculator2'
# 原生app的话要在activity前面加'.'
desired_caps['appActivity'] = '.Calculator'
desired_caps['automationName'] = 'uiautomator2' #主要自动化代码里面需要使用所以开了ui2模式,但测试代码里不需要用到
driver = webdriver.Remote(url, desired_caps)
for i in range(0, 10):
time.sleep(1)
driver.find_element_by_id('com.android.calculator2:id/digit%s' % i).click()
driver.find_element_by_id('com.android.calculator2:id/del').click()
driver.quit()
if __name__ == '__main__':
t1 = threading.Thread(target=test, args=('MYV0215A08011601', 'http://localhost:4723/wd/hub'))
t2 = threading.Thread(target=test, args=('EJLDU16804019826', 'http://localhost:4725/wd/hub'))
t1.start()
t1.join()
t2.start()
t2.join()
求助各位社区会员啊