Showing posts with label ADB. Show all posts
Showing posts with label ADB. Show all posts

Thursday 9 September 2021

Create AVD virtual device using Android studio and install APK

 How to Create New AVD (Virtual Device) In Emulator in Android Studio and Install Apk


We start AVD in Emulator to test our Android App. AVD Manager is basically a tool that you can use to create and manage AVD (Android Virtual Devices) for the Android Emulator. It is also called Emulator.


  1. OPEN Android Studio Select Tools -> Android -> AVD Manager -> Click the AVD Manager icon in the toolbar. You can also open AVD Manager directly by clicking the AVD icon in the Toolbar.
  2. Android Virtual Device Manager will be opened. After that Click on Create Virtual Device.
  3. After that choose the Category, phone size and choose the pixels according to your requirement. After this click on the Next button.
  4. After that choose the SDK Version and Click on the Next button. If you have various SDK Versions like 11, 12 and 10 etc in your SDK then you can select one of them. 
  5. Enter the AVD Name in Android Virtual Device and click on the Finish button. Here you can do customization to AVD which you are creating as per your requirement.Click Finish and a new AVD will be created.
  6. Now again open AVD manager and you will see your newly created AVD (Android Virtual Device) is added to the list.Click to Start the Virtual Device green play button
  7. After that, your AVD will start in Emulator. Now you can run your App in this AVD.

    Drag and drop the app from System to Simulator to install it.
Look below video to understand the whole process in detail:


Tuesday 9 March 2021

How to kill Appium server if device is not connected | How to find connected Android device

Subscribe to my youtube channel for more videos here:

Problem:

If the Android device was not connected during Appium Automation, it was starting the Appium server but was not able to quit it.
So, once running the script again after connecting the device , we will get error

Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]

Below is the script which I created to handle the situation and check if the device is already connected.
If it is not connected just Quit the Appium Server.

Solution:

if (loadPropertyFileAndroid.startsWith("Android_")) {

try {
Process process = Runtime.getRuntime().exec("adb devices");
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;

Pattern pattern = Pattern.compile("^([a-zA-Z0-9\\-]+)(\\s+)(device)");
Matcher matcher;

while ((line = in.readLine()) != null) {
if (line.matches(pattern.pattern())) {
matcher = pattern.matcher(line);
if (matcher.find()) {
System.out.println("android device connected");

AppiumServer.start();
CommonUtils.loadAndriodConfProp(loadPropertyFileAndroid);
log.info(loadPropertyFileAndroid + " properties file loaded !!!");
CommonUtils.setAndroidCapabilities();
driver = CommonUtils.getAndroidDriver();
String connectedDeviceName = driver.getSessionDetail("deviceName").toString();
System.out.print("Saif "+connectedDeviceName);

log.info("Appium server started");
}else{
AppiumServer.stop();

log.info("Appium server not started");
}

}
}
} catch (IOException e) {
e.printStackTrace();
}
Read about automation coding standards here: Avoid Mobile Automation Coding Pitfalls : Automation coding standards

Sunday 25 October 2020

Performing Monkey Testing on Android Device | Android | ADB



As per the Google blog:


Monkey is a program that runs on emulators and devices. Generates pseudo-random streams of user events such as clicks, touches, gestures, and system-level events. With Monkey, you can stress test your app in a random yet reproducible way.


Monkey can be launched from the development machine or script using the command line. The monkey runs in an emulator or device environment, so you need to launch it from a shell in that environment. To do this, adb shell either prefix each command or enter its shell and enter the Monkey command directly.


Command to be used: 


adb shell monkey -p com.sec.android.app.popupcalculator 1000 > internalsearch.txt


This command can be broken down into these steps.


ADB - Android Debug Bridge. A tool used to connect and sends commands to your Android phone from a desktop or laptop computer.



Shell - Shell is just an interface on the device that translates our commands to system commands.


Monkey - Monkey is the testing tool.


v - v stands for verbose method.


1000- it is the frequency count or the number of events to be sent for testing.


I am saving the logs in internalsearch.txt file



Below is the video from my youtube channel on how to do monkey testing.





Ref: https://developer.android.com/studio/test/monkey

Wednesday 24 October 2018

Shell script for debugging Android Application in Wifi mode


Shell script for debugging Android Application in Wifi mode



To Start first confirm your device is available in ADB mode, open the terminal and type below cmd:

adb devices




Once device is available,type


adb tcpip 5555



Now Search for the IP address of your device by

`adb shell ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'`



Remove your device from USB mode and connect it to the same wifi network as your system 

Now run the below command to 

adb connect <ip address of the device>:5555



The same step can be performed from the shell script I have written,just download the .sh file and run it with ./


Interview Experience with AMAZON for the role of Quality Assurance Tester

This role was for Digital/ IoT/Mobile Application based testing :)  Amazon is a dream company and everyone wants to work for that company a...

Popular Posts