Appium execution on real devices USB /WiFi
1 Execution on real devices using USB -
Assume all the below Prerequisites are installed and
configured :-
1. JDK should be installed
2. Android should be installed and path should be setup in your machine
2. Android should be installed and path should be setup in your machine
3. Appium should be installed.
4. Configure Device with Developer Mode option enabled
4. Configure Device with Developer Mode option enabled
In order to run Appium
test cases on real devices, we need to connect real android device to PC by
enabling USB debugging mode.To test on a real device or on on a simulator, we
need SDK to be installed on your machine. Appium will take the advantage of the
SDK to connect to the real device connected via USB or simulator.
First Enable Developer Option, To enable
Developer Option in android device, Click on Settings and find out ‘About
Phone’ option.
Follow below steps –
Step 1 : Click on
About Phone option
Step 2 : Click on
Version Information
Step 3 : Now you
will find an option called ‘Build Number’.
Step 4 : Keep
clicking Build number option for seven times. It starts showing you information
message as ‘You are now 2 steps away from being a developer’
Step 5 : and again
‘You are now 1 step away from being a developer’
Step 6 : And After
clicking for 7 times, finally it will show a message as ‘You are now a
developer!’
Step 7 : Now you
can see ‘Developer Options’ from where you can enable ‘USB debugging’.
Step 8 : Click on
‘Developer Options’, which will show you multiple options available
Step 9 : Check
‘USB debugging’ option, Once we check that option, it will display warning
Step 10 : Click on OK to continue. Done!!!!! Now we have successfully
enabled USB debugging mode for android device.
Finally, To make sure if the device is
connected properly with USB debugging mode, we can check using command prompt,
Open command prompt and enter ‘adb devices’, which will show you the device
connected.
To check this open command prompt and type
abd devices
this will give list of connected devices and there name.
2.
Execution on real devices using WiFi –
Before proceeding further, you should make sure Android SDK is
configured in your machine AND should have enabled ‘USB debugging’ from
'Developer Options' in your android device.
Step 1 :- Connect your device to computer via USB and
check if it is connected using 'adb devices' which will list you the devices
connected to your machine.
Step 2 :- We should
make sure that android device and the PC are connected to the same Wifi network.
Step 3 :- Now we
need to restart adb and make it work over tcpip by specifying the port value.
If no port number is specified, Port 5555 is used by default.
adb tcpip <port>
In the above command, 'adb
tcpip' command actually tries to reconfigure and restart the adb daemon on the
device. By default in most of the cases it will be using USB. After executing
the above command adb daemon will now start listening to tcpip.
Step 3 :- Now
disconnect the device which is connected to PC
Step 4 :- We need
to get the IP address of the the device. There are two ways to get IP address
of your device
Firstly, you can get that from your device -> Settings ->
Wifi -> Wifi Settings / You can click on your wifi network which will popup
details
Alternatively, we can run the
command 'adb shell ip -f inet addr show
wlan0' which will show you the ip address of the connected device.
Step 5 :- Run the
below command to connect adb to your device over Wi-Fi using IP address of your
device:
adb connect device_IP_Address
Now we can execute our tests
on Real device over wifi. Let us now connect multiple Android Devices
over Wifi and execute our tests.
How to execute
Appium Tests On Real Android Device over Wifi with Multiple Devices?
Step 1 :- Connect your
device ONE to PC
Step 2 :- "adb tcpip "
Step 3 :- Disconnect the device from the PC
Step 2 :- "adb tcpip "
Step 3 :- Disconnect the device from the PC
Step 4 :- Now Connect your
device TWO to PC
Step 5 :- "adb tcpip "
Step 6 :- Disconnect the device from the PC
Step 5 :- "adb tcpip "
Step 6 :- Disconnect the device from the PC
Step 7 :- Get the IP
addresses of the two devices [explained ways to get IP address above], and run
below command to connect adb to your device over Wi-Fi using IP address of your
device:
adb connect deviceONE_IP_Address
adb connect deviceTWO_IP_Address
Example : -
adb connect 10.0.0.2 // IP address of device ONE
adb connect 10.0.0.6 // IP address of device Two
adb connect 10.0.0.2 // IP address of device ONE
adb connect 10.0.0.6 // IP address of device Two
Remember, Now again when we want to switch
to USB mode, we have to tell the ADB daemon return to listening over USB.
Enter below command:
#To Set back the port to USB, so the next time when ADB is
started, it will start on USB again.
adb usb
Try the following steps and it should bring your device back.
adb kill-server
adb start-server
adb devices
adb start-server - Which will ensure that there is a server running
adb kill-server - This command Will kill the server if it is running
adb kill-server - This command Will kill the server if it is running
Comments
Post a Comment