How to use do_proxy_usbmux method in Airtest

Best Python code snippet using Airtest

instruct_cmd.py

Source:instruct_cmd.py Github

copy

Full Screen

...89 if proxy_process:90 cmds = [proxy_process, "-u", self._udid, str(local_port), str(device_port)]91 else:92 # Port forwarding using python93 self.do_proxy_usbmux(local_port, device_port)94 return95 # Port forwarding using iproxy96 # e.g. cmds=['/usr/local/bin/iproxy', '-u', '00008020-001270842E88002E', '11565', '5001']97 proc = subprocess.Popen(98 cmds,99 stdin=subprocess.PIPE,100 stdout=subprocess.PIPE,101 stderr=subprocess.PIPE,102 creationflags=SUBPROCESS_FLAG103 )104 # something like port binding fail105 time.sleep(0.5)106 if proc.poll() is not None:107 stdout, stderr = proc.communicate()108 stdout = stdout.decode(get_std_encoding(sys.stdout))109 stderr = stderr.decode(get_std_encoding(sys.stderr))110 raise AirtestError((stdout, stderr))111 self.cleanup_handler.append(proc.kill)112 def do_proxy_usbmux(self, lport, rport):113 server = ThreadedTCPServer(("localhost", lport), TCPRelay)114 server.rport = rport115 server.device = self.usb_device116 server.bufsize = 128117 self.server = server118 self.server_thread = threading.Thread(target=self.server.serve_forever)119 self.server_thread.daemon = True120 self.server_thread.start()121 self.cleanup_handler.append(self.server.shutdown)122if __name__ == '__main__':123 ins = InstructHelper()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful