需要的环境有:nodejs java adb python-client
通过npm安装appium:npm --registry http://registry.npm.taobao.org install appium -g
启动代码如下:
import os
import time
from multiprocessing import Pool
def start_appium(port=4723, udid=""):
while 1:
a = os.popen('netstat -ano | findstr "%s" '% port)
time.sleep(2)
t1 = a.read()
if "LISTENING" in t1:
print("appium服务已经启动:%s" % t1)
time.sleep(6000)
else:
# 启动appium服务
try:
print("准备启动Appium服务。。。")
b = os.system('appium -a 127.0.0.1 -p {}'.format(port))
except Exception as e:
print(e)
# return ""
else:
print("服务已启动。。。")
if __name__ == "__main__":
appium_port_list = [4723, 4725, 4727, 4729, 4731, 4751, 4761]
p = Pool(8)
for port in range(len(appium_port_list)):
p.apply_async(start_appium, args=(appium_port_list[port],))
p.close()
p.join()