当前位置:网站首页>Teach you how to use airtestide to connect your mobile phone wirelessly!

Teach you how to use airtestide to connect your mobile phone wirelessly!

2022-06-24 12:59:00 AirtestProject

1. Preface

all the time , We found that students like to connect their mobile phones wirelessly , Just Android 11 A new posture of wireless connection , Let's have a look today , How to use AirtestIDE Wirelessly connect your Android equipment ~

2. Android11 The following wireless connection methods

When Mobile phones and computers are in the same place wifi Next , You can try to connect your phone wirelessly , However, this method is limited by the stability of network connection , The connection may not be stable enough .

about Android11 The following equipment , The specific connection steps are as follows :

1) Cell phone on USB debugging

Make sure the phone is turned on USB Debugging options , And first use USB The cable connects the mobile phone to the computer ( Here's a point , Many students will ignore this step !)

2) The computer side executes adb tcpip 5555

Execute commands on the computer adb tcpip 5555 , among 5555 It's the port number , You can specify... According to your own needs ,5555 Is the default value .

image

If you're executing adb tcpip 5555 When , Found an error error: no devices/emulators found , The big probability is , You didn't turn on your cell phone USB Debugging function , Please go back to the first step and read and operate again .

image

3) Get a cell phone IP Address

Get a cell phone IP Address , Can be in Phone settings - About mobile phone - State information -IP Address Found in :

image

4)IDE Enter the connection string

And then You can pull it out USB Line ( To this step , You can unplug USB Line !) , stay AirtestIDE Of Remote device connection Place input adb connect mobile phone ip: The port number just filled in 5555 , for example adb connect 10.228.36.xx:5555 , Click to connect , Refresh ADB After that, you can see the connected devices in the device list :

image

image

5) Disconnect and retry

If because of network fluctuations 、 restart ADB The connection is disconnected due to other reasons , Do it again adb connect ip:port that will do .

6) Particular attention

Android11 The following equipment , Use a wireless connection , At the beginning, you still need to use USB Connect the phone and computer with the cable , Designated port 、 Inquire about IP after , Before you can pull it out USB Line !!!

3. Android11 Wireless connection mode

At the beginning we mentioned ,Android11 Wireless connectivity has a new posture ! Namely You don't need to go all the way USB Line 了 , Very happy , Just like Bluetooth pairing .

Let's talk about it in detail ,AirtestIDE How to connect wirelessly Android11 The equipment !

1) Make sure that the ADB yes 41 edition

Personal test , If you want to use a new pose to connect wirelessly Android11 The equipment ,adb40 Can't meet our needs anymore , So I'd better put the computer inside honestly adb Upgrade to 41 Well .

We can use adb --version To check the inside of the computer ADB Version :

image

2) Cell phone on USB debugging

In your Android11 On the device , Turn on USB debugging Options .

3) Enable wireless debugging options

find USB Debug the following Wireless debugging Options , Click the open button on the right :

image

4) Pairing device with pairing code

And then click Wireless debugging ( A little magical interaction , But that's how you go to the next menu ...), Click again Pairing device with pairing code , You can see the matching with the device WLAN Pairing code and IP Address 、 Port or something :

image

At this point, you can open the terminal on our computer , Enter the matching command , Started matching with our mobile devices :

adb pair 10.228.57.xx:port

image

After a successful match , We can also see our... From the paired device of the mobile phone PC Equipment information :

image

5) Query device IP

Still in the wireless debugging interface , You can find our equipment IP And port :

image

6)adb connect Wireless devices

stay PC Used in the terminal of adb connect ip:port Connect this device :

image

7)IDE Connect

stay IDE Internal connection Android11 Wireless devices , In the same way as the above equipment , Just one thing we need to pay attention to , We just used adb41 For device pairing and adb connect Of , therefore Need to put IDE Inside ADB It is also replaced by a unified 41 edition ( at present IDE Using all of these 40 edition , We will also upgrade to 41 edition ), If you do not replace the version , Because of adb The versions are not uniform , There was a conflict and we couldn't connect Android11 Wireless devices :

image

tips: How to make IDE Inside adb Replace with 41 edition

On the official platform developed by Android , find SDK The platform tools :https://developer.android.com/studio/releases/platform-tools?hl=zh-cn , Download the latest Android SDK Tools , After decompression , Find the inside adb Tools :

image

hold ADB Of 3 Copy out files , And to the IDE In the corresponding directory of , Replace the original 40 edition :

image

4. pure Airtest Scripts connect to wireless devices

IDE We've gone through the details of how to connect wireless devices , Let's add here , pure Airtest Script way to connect wireless devices :

#  Mode one 
auto_setup(__file__, devices=["Android://127.0.0.1:5037/ip:port"])

#  Mode two 
connect_device("Android://127.0.0.1:5037/ip:port")

#  Mode three 
init_device(platform="Android",uuid="ip:port")

#  among ,ip:port, Wireless devices ip Address and port number 

5. Summary

Today's tweet mainly explains the following :

  • Android11 Wireless connection mode of the following devices
  • Android11 And the wireless connection mode of the above equipment
  • How to make IDE in 40 Version of ADB Replace with 41 edition
  • pure Airtest Connect wireless devices in script mode

In fact, for Android11 The following equipment , and Android11 For the above equipment , The biggest optimization of the wireless connection mode is ,Android11 And above devices do not need to be connected to the data line to prepare for wireless connection , And after the device is paired successfully , as long as PC In the same place as the mobile device wifi Next , Can be directly connected , No need to reconnect the data cable 、 Pairing and so on , Very convenient !


Airtest Official website https://airtest.netease.com/
Airtest Official website of the course https://airtest.doc.io.netease.com/
Build enterprise private cloud services https://airlab.163.com/b2b

Official Q & A Q Group :117973773

ah , You've seen it so seriously , Please give me a recommendation and support , Thank you very much ~

原网站

版权声明
本文为[AirtestProject]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241146517758.html