def set_chromedriver(self, device_ip=None, package=None, activity=None, process=None): driver = ChromeDriver(self.d, Ports().get_ports(1)[0]). \ driver(device_ip=device_ip, package=package, attach=True, activity=activity, process=process) return driver
def main(): # read all devices on this PC devices = Devices().get_devices() # read free ports on this PC ports = Ports().get_ports(len(devices)) if not len(devices): print('there is no device connected this PC') return runs = [] runs.append(RunCases(devices[0], ports[0])) # start macaca server macaca_server = MacacaServer(runs) macaca_server.start_server() drive(macaca_server.server_url(runs[0].get_port()), runs[0]) macaca_server.kill_macaca_server()
def run(self, cases): # read all devices on this PC devices = Devices().get_devices() print("devices的列表:") print(devices) # read free ports on this PC ports = Ports().get_ports(len(devices)) print('ports的列表:') print(ports) if not len(devices): print('there is no device connected this PC') return runs = [] for i in range(len(devices)): runs.append(RunCases(devices[i], ports[i])) print('runs的列表:') print(runs) # start macaca server macaca_server = MacacaServer(runs) macaca_server.start_server() # run on every device pool = Pool(processes=len(runs)) index = 0 for run in runs: pool.apply_async(self._run_cases, args=(macaca_server.server_url(run.get_port()), run, cases, index,)) index += 1 # fix bug of macaca, android driver can not init in the same time time.sleep(2) pool.close() pool.join() macaca_server.kill_macaca_server()
def run(self, cases): # read all devices on this PC devices = Devices().get_devices() # read free ports on this PC ports = Ports().get_ports(len(devices)) if not len(devices): print('there is no device connected this PC') return runs = [] for i in range(len(devices)): runs.append(RunCases(devices[i], ports[i])) # start macaca server macaca_server = MacacaServer(runs) macaca_server.start_server() for port in ports: while not macaca_server.is_running(port): print('wait macaca server all ready...') time.sleep(1) print('macaca server all ready') # run on every device pool = Pool(processes=len(runs)) for run in runs: pool.apply_async(self._run_cases, args=( macaca_server.server_url(run.get_port()), run, cases, )) # fix bug of macaca, android driver can not init in the same time time.sleep(2) pool.close() pool.join()