Example #1
0
 LOG.info("测试开始执行")
 start_time = datetime.datetime.now()
 makecasefile('reg', 'reg', 'reg')
 path = os.getcwd()
 filenm = path + '/testreport/' + 'result.xls'
 devicess = connectmobile()
 listport = []
 if len(devicess) > 0:
     for dev in devicess:
         app = {}
         app["devices"] = dev
         port = str(random.randint(4593, 4598))
         app["port"] = port
         l_devices.append(app)
         listport.append(port)
     appium_server = AppiumServer(l_devices)
     appium_server.start_server()  # 启动服务
     runnerPool(l_devices)
     try:
         appium_server.stop_server(listport)
     except Exception as e:
         print("关闭服务失败,原因:%s" % e)
         LOG.info("关闭服务失败,原因:%s" % e)
     end_time = datetime.datetime.now()
     hour = end_time - start_time
     s = StfPhoneOpear()
     for i in devicess:
         LOG.info("---归还设备:%s -----" % i['serial'])
         s.removeroneophen(i["serial"])
     create(filename=filenm, devices_list=devicess, Test_version='2.0.1', testtime=str(hour))
     LOG.info("测试执行完毕,耗时:%s" % hour)
Example #2
0
 if Test_mobile_type == 'Android':
     devicess = AndroidDebugBridge().attached_devices()
 else:
     #todo 本地获取链接的ios设备
     pass
 makecasefile('reg', 'reg', 'reg')  # 没有的时候才会生成,一般都会有这个文件
 path = os.getcwd()
 report_path = os.path.join(path, "testreport")
 filenm = report_path + 'result.xls'
 if len(devicess) > 0:
     for dev in devicess:
         app = {}
         app["devices"] = dev
         app["port"] = str(random.randint(4593, 4598))
         l_devices.append(app)
     appium_server = AppiumServer(l_devices)
     appium_server.start_server()  # 启动服务
     runnerPool(l_devices)
     try:
         appium_server.stop_server(devicess)
     except Exception as e:
         LOG.info("关闭服务失败,原因:%s" % e)
     end_time = datetime.datetime.now()
     hour = end_time - start_time
     create(filename=filenm,
            devices_list=devicess,
            Test_version=testversion,
            testtime=str(hour))
     LOG.info("测试执行完毕,耗时:%s" % hour)
 else:
     LOG.info("没有可用的安卓设备")