Table of Contents

 1. In which form you get the build for Android and iOS platforms? 

  • For Android file with .apk extension and for iOS .app or .ipa.

2. What are the minimum and maximum OS versions the app can be tested on?

It is set by product owner and technical team. You can get the information by using adb command. One of which is the dumpsys command.

For this example, general store app is installed, run “adb shell dumpsys package com.androidsample.generalstore ”.

This will return a big list , we can filter it using grep  “adb shell dumpsys package com.androidsample.generalstore | grep versionName” returns “versionName=1.0”.

or “adb shell dumpsys package com.androidsample.generalstore | grep versionCode” returns “versionCode=1 minSdk=21 targetSdk=28”, which shows minimum Android version that is supported and the version that is targeted by the build.      

3. In today’s world having such a wide range of devices as a QA how would you decide which devices need to be picked for testing?

  • Generally BI and technical teams decide it by running surveys and using third party software such google firebase which can give the percentage wise usage of devices in a particular region.

4. How to get crash logs in Android and iOS?

  • In android you can get it via logcats. Android studio is very useful to filter the logs.

         Generally crash logs start with FETAL MAIN EXCEPTION.

          For Mac console app can be used. More info at

https://eshop.macsales.com/blog/45586-how-to-use-the-mac-console-app-to-diagnose-a-crash/

5. How to perform Locale testing (in context of different part of the world).

6. How do you perform performance testing in mobile?

7. How do you simulate different  network conditions?

8. How to test Deep links on mobile?

9. How do you monitor/test network traffic in mobile apps? Charles Breakpoints in charles and usage.

10. How to change values in responses using charles?

11. How to install and uninstall app using adb?

  • Adb install <path/to/the apk>

12. How to record screens using adb?

  • Screen record – A very useful tool that I use several times a day is the screen record command: “adb shell screenrecord /sdcard/sampleVideo.mp4”. As you’d expect, this will record the screen for a max of 3 mins. When you want the recording to stop, press ctrl+c on your keyboard and the pull the file onto your pc,

13. How to change battery level adb?

  • One of my favorite adb commands is the battery manipulation commands:
  • “adb shell dumpsys battery” will provide a read-out of all battery     related information.
  • “adb shell dumpsys battery set level 5” will set the battery level to 5. Very useful for low battery testing on Android. However, since the device is still connected to your PC, we need to make it seem like it is not charging, so use the following in conjunction:
  • “adb shell dumpsys battery unplug” makes the device appear as unplugged.
  • When you are all done with your testing, use the following to reset all battery configs: “adb shell dumpsys battery reset”.
  • There are other commands such as “adb shell xdumpsys battery set status 3”, for instance, which fakes battery discharge etc.

14. How to push files to device/emulator using adb?

  • Push files to device – Often times you need to push files or folders to the device.
  • a. Use the following for this: “adb push /file/on/computer /sdcard/”, this will put a file in your root folder.
  • b. Or say you have a media payload on your computer you want in your Downloads folder on your device: “adb push/Users/xyz123/Desktop/Payloads/sdcard/Downloads”.
  • c. This is especially useful when pushing a debug property file to your device or a Charles certificate: “adb push /Users/xyz123/Desktop/PropFiles-Highlights/syncdrive-bt-debug.properties /sdcard/”.

15. How to filter debug logcat logs?

  • Using sample command. This command shows how we can filter logs from a particular apps. “adb logcat | findstr com.example.package”

16. What is signed apk?

  • Application signing ensures that one application cannot access any other application except through well-defined IPC. When an application (APK file) is installed onto an Android device, the Package Manager verifies that the APK has been properly signed with the certificate included in that APK.

17. Tell me a few known device farms.

    Browserstack, SeeTest, Pcloudy, Saculabs etc.

18. How do you identify that it is a hybrid application?

Yes, there is a simple way to distinguish between hybrid and native app. Go to Developer Options from Settings and turn on Show Layout bounds. And then launch your app and see the layout highlighted. If there are lots of rectangles highlighted, it's native. Otherwise hybrid.

19. Can you break the .apk file and analyze the source code?

Analyze APK and view Android Manifest – This is a useful task that is sometimes required during testing. This method provides the most information about an app including various assets, images, animations, colors, fonts, strings, Spanish strings, api information, screen sizes supported, supported architectures, supported devices/manufacturers, contact account information, layout information such as font sizes, padding, and much more. Follow the following steps to analyze an APK:
a. Launch Android Studio on your computer and Select ‘Start a new Android Studio
project. Select ‘Next’ a few times and then select ‘Finish’ (these details are not
important for what we need to do).
b. In the top pane, select the ‘Build’ drop down menu and then select ‘Analyze
APK.’ Using the file browser on screen, navigate to the APK file you want to
explore. Select it and hit ‘OK.’ This will take some time to load.
c. From here you can click around on the various drop-down menus and view all of
the available content. “AndroidManifest.xml” will be displayed towards the top.
Note – use a debug APK for this.

20. How do you perform tests in a cloud environment?

https://www.browserstack.com/docs/app-automate/appium/getting-started/java

21. Testing your app with faceID.

     https://appiumpro.com/editions/80-testing-ios-face-id-with-appium

22. Working with different permissions and other Adb commands.         

Grant/Revoke permissions – Sometimes it can be useful when testing to revoke or grant a permission at a specific point in the app flow, without launching settings, or maybe there is a hidden permission that cannot be revoked within settings. To do this, you will need to get a read-out of all the Android permissions,

a. As an example, lets revoke the storage permission of the XYZ app, after having granted it in the UI. For this, we need to revoke read and write permissions, so I will join to adb commands together as such: “adb shell pm revoke com.xyz.android.xyz android.permission.READ_EXTERNAL_STORAGE && adb shell pm revoke com.sfr.android.sfrcloud android.permission.WRITE_EXTERNAL_STORAGE”. Now if you check App settings, storage will be revoked. As a tip, you can combine any ADB commands using the “&&” concatenation command. Just make sure you call “adb” again in xthe 2nd command, or else it will throw an error.

b. The same can be done for granting permissions: “adb shell pm grant com.xyz.android.xyz android.permission.READ_EXTERNAL_STORAGE && adb shell pm grant com.xyz.android.xyz android.permission.WRITE_EXTERNAL_STORAGE”. And you can swap out the package with any app you would like and also the permission you choose.

Reboot/Download – To restart an Android device via ADB, simply run “adb reboot”. To restart an Android device in download mode, which is used when you would like to load a new firmware on the device, run “adb reboot download”.

Get Network Info – To quickly and easily get network info of your device, run the following: “adb shell netstat”. This can be especially useful when trying to get the IP address that is used for #14 above.

Get device features – Sometimes it is useful to have a readout of all device features.

This can be useful when determining what app features should function with this device or if an app should even be installable on a device, e.g. tablet vs. foldable device vs. TV vs. standard handset. To do this, run: “adb shell pm list features”.

Clear app storage – To quickly and easily clear app storage of an installed app, run the following: “adb shell pm clear com.att.personalcloud”. To get the package name, use #4 or #13 from above.

Make calls and send text – For testing purposes, sometimes we need to test call/text processes while also carrying out a task in the app. To do this, simply run the following commands:

a. Call – “adb shell am start -a android.intent.action.CALL -d tel:+19085552244”

b. Text – “adb shell am start -a android.intent.action.SENDTO -d

sms:+19085552244 --es sms_body "Test" --ez exit_on_sent false”

23. What is a web debugging proxy?

Also known as HTTP monitor or Reverse Proxy, that allows the tester to view all of the HTTP and SSL/HTTPS traffic between their machine and the Internet. ... This includes requests, responses, and HTTP headers. Example: Charles.

24. What are some of the important mobile application testing?

Usability Testing: Usability testing is one of the sorts of web application testing that is perfect for assessing how the application makes it easier for users to achieve their goals. During this test, participants are given particular, realistic circumstances to use the application in. On the basis of gathering direct input from the end-user, usability testing is also reliable.
As a result, the testing procedure is free of prejudice while simultaneously guaranteeing that highlighted areas improve. Usability testing also ensures that the design is intuitive and prioritises usability and customer experience.

Performance Testing: Performance testing is a critical subset of mobile application testing that examines an application's performance, stability, and responsiveness under various workload situations. A performance test's main goal is to ensure that an application is completely aligned with the performance objectives.
Additionally, it addresses performance constraints prior to launching an application. Bottlenecks are processes inside a system's overall functions that cause the system's overall performance to slow or stall. Load testing, volume testing, soak testing, spike testing, and stress testing are all popular forms of performance assessments.

Security Testing: In today's world, security is a major worry for practically every mobile application developer. According to reports, 80% of users are more likely to delete an application because of security concerns. As a result, it is critical to concentrate on mobile application security testing.
Users' personal information is required by certain programs, such as travel applications, for various transactions. If your application requires something similar, it's critical that you provide assurances about the application's confidentiality, integrity, and authenticity. You should have strong tests run on your application that assure that no one can break into someone else's account by unfair means.

Interruption Testing: Interruption testing is important for determining how an application behaves when it is interrupted before returning to its former state. Incoming phone calls or SMS, alarms, push notifications from mobile applications, battery low or full, network connection loss and recovery, and plugged in or out while charging are all examples of interruptions. In the event of an interruption, an application should normally run in the background and return to its prior state.

Manual Testing: Manual testing is a tried and true method for thoroughly traversing the complexity of mobile application testing. Manual testing ensures that the finished product performs optimally in accordance with the planned expectations. It's especially useful in situations where the use case isn't immediately evident. Professional QA testers could work in short bursts to assess an application and ensure that it produces accurate results.

Compatibility Testing: Compatibility testing is one of the most important types of mobile application testing. It's a form of non-functional testing that ensures a mobile application's functionality across a variety of operating systems, applications, devices, internal hardware specs, and network conditions. Compatibility testing determines whether a mobile application is compatible with various operating systems and versions.
It also tests a mobile application's compatibility with various devices, browsers, networks, and other characteristics. Backward compatibility testing and forward compatibility testing are the two types of compatibility testing.

Localisation Testing: Localization testing is a must for mobile applications that are targeted at a certain geographic location. It's crucial to test the mobile application's responsiveness to the region's distinct language and cultural aspects. Local currency, use of suitable time zone date and time formats, numerous local legislation needs, and the text and user interface are only a few of the important areas that localization testing evaluates.

Functional Testing: Functional mobile application testing ensures that the application's functionalities meet the specified requirements. This form of testing focuses mostly on the mobile application's main goal and flow. Functionality testing determines if an application can properly launch and install. It also tests the simplicity of sign-up and login, as well as the presentation of push notifications and the proper operation of text boxes and buttons.

Installation Testing: Installation testing, also known as implementation testing, is a good way to ensure that a mobile application is installed and removed correctly. Furthermore, installation testing is necessary to ensure that updates are seamless and error-free. Installation testing also examines what happens if users fail to update a mobile application.

Automated Testing: Certain mobile application quality assessments are overly complicated and time-consuming. In such instances, Mobile application Test Automation Services come into play, providing optimally prepared and effectively conducted automated testing as well as manual testing, which can aid in assuring quality while also allowing for the speedier release of superior goods. As a result, automated testing is a solid source of time and cost savings when it comes to mobile application testing. There are various tools to perform automated testing. Appium is one of them.

Mention the Different Types of Mobile Applications.

Mobile applications can be broadly categorized into three categories i.e, Native app, Web app and Hybrid App.

Native App: Native app is developed specifically for one platform, which is coded with a specific programming language (like Objective C for iOS, Java for Android) and installed directly onto the device and can take full advantage of all the device features. Native apps can use the device’s notification system and can work offline. Native apps are installed through an application store (such as Google Play or Apple’s App Store). Native mobile apps provide fast performance and a high degree of reliability. Example of native apps: Temple Run, Candy Crush, etc.

Web App: Web applications are mobile web portals that are designed, customized and hosted specifically for mobiles. They are accessed through the mobile device’s web browser using a URL. Web apps became really popular when HTML5 came around and people realized that they can obtain native-like functionality in the browser. Mobile web applications cannot use device functionality. Example of web app: google.com, m.snapdeal.com, m.yahoo.com, etc.

Hybrid App: Hybrid Apps are web apps embedded in a native app, run on the device, and are written with web technologies (HTML5, CSS, and JavaScript). Hybrid apps run inside a native container and leverage the device’s browser engine (but not the browser) to render the HTML and process the JavaScript locally. A web-to-native abstraction layer enables access to devices capabilities that are not accessible in mobile web applications, such as the accelerometer, camera, and local storage. A hybrid app is NOT tied to any platform or any particular mobile device. So, it can run on any device once built. Example of a Hybrid app: Flipkart, Facebook, Twitter, etc.

25. What are the main advantages Of Using Appium On Sauce Labs?

Saves the time it takes to set up the appium server locally.

You  don’t  have to install/configure the mobile emulators/simulators in your local environment.

You don’t have to make any modifications to the source on your application.

We can start scaling applications instantly.

26. Consider A Scenario Where You Don’t Want To Setup A Whole Infrastructure, And Neither Spend Money. Can Appium Help Out In Such A Scenario?

If you think about it, what really is required is the test script. The fact that you must deploy an Appium server somewhere is just an extra feature. If you want to skip this part, you can rely on some web services that have already deployed a whole architecture of Appium servers for your tests. Most of them are online labs and they support Selenium and Appium. In this way, you don’t spend exorbitant amounts of money and you also don’t invest time and effort on new infrastructure.

27. What Are The Problems Faced While Running A Test In A Multithreaded Environment?

You need special care while using Appium in a multithreaded environment. The problem does not rely on the fact of using threads in your tests. You can use them but, you must ensure that no more than one test runs at the same time against the same Appium server. Appium does not support multiple sessions, and unless you have implemented an additional layer on top of it to handle this case, multiple tests might fail.

28. List OneThing Which You Cannot Do With Emulators But You Can Do With A Real Device.

  • You can test the interrupts like
  • Phone calls & Messages
  • Battery drains out while using the application under test
  • Low battery scenarios
  • Memory card mount/unmount scenarios
  • Actual performance of your application
  •  Bluetooth related testing.

29. What do you understand by Appium package master? How would you create a package?

Appium package master is a set of tools used to manage and create Appium packages. We can use the following code to create a package:

# using es7/babe1:

Gulp create-package -n <package-name>

#regular es5:

Gulp create-package ---nobabe1 -n <package-name>

The package will be generated in the out/<package-name>

30. Any Tips Or Tricks To Speed Up My Test Writing Activity while I develop test scripts?

Here is one piece of advice. Since your tests will mostly consist in automation tasks, make interactions reusable!

Do not write the same sub-scenarios twice in your tests, make a diagram of what your scenarios are and split them in sub activities; you will get a graph where some nodes are reachable from more than one node.

 So make those tasks parametric and call them in your tests! This will make your test writing experience better even when you need to migrate from existing tests.


31. Can you write generic code to generate webdriver instance using Appium APIs for both Android and IOS?

import java.io.File;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;


import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Reporter;


import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.MobileCapabilityType;


public class AppiumDriverFactory {


private static Logger logger;
private static EnvironmentPropertiesReader configProperty = EnvironmentPropertiesReader.getInstance();

public static AppiumDriver<MobileElement> getDriverInstance() {
return get();
}

private static AppiumDriver<MobileElement> get() {
AppiumDriver<MobileElement> driver = null;
try {
driver = getAppiumDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
catch (Exception e) {
Log.fail("Could not create a driver session");
}

return driver;
}

private static AppiumDriver<MobileElement> getAppiumDriver() throws MalformedURLException {
AppiumDriver<MobileElement> driver = null;
DesiredCapabilities capabilities = getDesiredCapabilities();
Log.testCaseInfo("Initialize the Appium driver...");
try {
String appiumURL = "http://" + configProperty.getProperty("hostName") + ":" + configProperty.getProperty("portName") + "/wd/hub";
capabilities = getDesiredCapabilities();
switch (configProperty.getProperty("platformName").toLowerCase())
{
case "android":
Log.testCaseInfo("Initializing Android Driver Instance using Appium Driver");
driver = new AndroidDriver<>(new URL(appiumURL), capabilities);
break;

case "ios":
Log.testCaseInfo("Initializing IOS Driver Instance using Appium Driver");
driver = new IOSDriver<>(new URL(appiumURL), capabilities);
break;
}
}

catch (Exception e) {
Log.fail("Unable to create driver session with given URL and DesiredCapabilities : " + e.getMessage());
}

return driver;
}

private static DesiredCapabilities getDesiredCapabilities() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
if(configProperty.getProperty("platformName").equals("iOS"))
{
Log.testCaseInfo("Setting Desired Capabilities for iOS Driver");
if(configProperty.getProperty("platformName")!=null)
capabilities.setCapability("platformName", configProperty.getProperty("platformName"));
Log.testCaseInfo("Platform Name set as : " + configProperty.getProperty("platformName"));

if(configProperty.getProperty("platformVersioniOS")!=null)
capabilities.setCapability("platformVersion", configProperty.getProperty("platformVersioniOS"));
Log.testCaseInfo("Platform Version set as : " + configProperty.getProperty("platformVersioniOS"));

if(configProperty.getProperty("udidiOS")!=null)
capabilities.setCapability("deviceName", configProperty.getProperty("udidiOS"));
Log.testCaseInfo("DeviceName Name set as : " + configProperty.getProperty("udidiOS"));

capabilities.setCapability("udid", configProperty.getProperty("udidiOS"));
Log.testCaseInfo("UDID set as : " + configProperty.getProperty("udidiOS"));

if (configProperty.getProperty("appPathiOS") != null) {
capabilities.setCapability(MobileCapabilityType.APP, configProperty.getProperty("appPathiOS"));
Log.testCaseInfo("APP path iOS set as : " + configProperty.getProperty("appPathiOS"));
}

}

if(configProperty.getProperty("platformName").equals("Android"))
{
Log.testCaseInfo("Setting Desired Capabilities for Android Driver");

if(configProperty.getProperty("deviceName")!=null)
capabilities.setCapability("deviceName", configProperty.getProperty("deviceName"));
Log.testCaseInfo("DeviceName Name set as : " + configProperty.getProperty("deviceName"));

if(configProperty.getProperty("platformName")!=null)
capabilities.setCapability("platformName", configProperty.getProperty("platformName"));
Log.testCaseInfo("Platform Name set as : " + configProperty.getProperty("platformName"));

if(configProperty.getProperty("platformVersion")!=null)
capabilities.setCapability("platformVersion", configProperty.getProperty("platformVersion"));
Log.testCaseInfo("Platform Version set as : " + configProperty.getProperty("platformVersion"));

if(configProperty.getProperty("installedAndroidApp").equals("false"))
{
Log.testCaseInfo("Setting android app apk path in Desired Capability.. ");

if(configProperty.getProperty("deviceName")!=null) {
Log.testCaseInfo("Device Name set as : " + configProperty.getProperty("deviceName"));
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, configProperty.getProperty("deviceName"));
}

if(configProperty.getProperty("appName")!=null) {
File f = new File("src");
File app = new File(f,configProperty.getProperty("appName"));
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
Log.testCaseInfo("App Path set as : " + app.getAbsolutePath() );
}
}
else
{
if(configProperty.getProperty("appPackage")!=null) {
Log.testCaseInfo("App Package set as : " + configProperty.getProperty("appPackage"));
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, configProperty.getProperty("appPackage"));
}

if(configProperty.getProperty("appActivity")!=null) {
Log.testCaseInfo("App Activity set as : " + configProperty.getProperty("appActivity"));
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, configProperty.getProperty("appActivity"));
}
}

Log.testCaseInfo("Command Time Out set as : " + configProperty.getProperty("commandTimeOut"));
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, configProperty.getProperty("commandTimeOut"));
}
return capabilities;
}

32. How to use Android soft keys options Ex. Home, recent apps, back button.

We can do that by using native key package. Below packages are available.

import io.appium.java_client.android.nativekey.AndroidKey;

import io.appium.java_client.android.nativekey.KeyEvent;

Custom methods can be created as.

public void pressHomeKey()

{

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.HOME));

}

public void pressBackKey()

{

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.BACK));

}

public void pressRecentAppKey()

{

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.MENU));

}

public void hideKeyBoard()

{

driver.hideKeyboard();

}

33. How to get status bar notification in Android.

Sample code:

public class Android_Notifications {

    private String APP = "https://github.com/cloudgrey-io/the-app/releases/download/v1.10.0/TheApp-v1.10.0.apk";

    private AndroidDriver driver;

    @Before

    public void setUp() throws Exception {

        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("platformName", "Android");

        capabilities.setCapability("deviceName", "Android Emulator");

        capabilities.setCapability("automationName", "UiAutomator2");

        capabilities.setCapability("app", APP);

        driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);

    }

    @After

    public void tearDown() {

        if (driver != null) {

            driver.quit();

        }

    }

    @Test

    @SuppressWarnings("unchecked")

    public void testNotifications() {

        Map<String, Object> res = (Map<String, Object>)driver.executeScript("mobile: getNotifications");

        List<Map<String, Object>> notifications = (List<Map<String, Object>>)res.get("statusBarNotifications");

        for (Map<String, Object> notification : notifications) {

            Map<String, String> innerNotification = (Map<String, String>)notification.get("notification");

            if (innerNotification.get("bigTitle") != null) {

                System.out.println(innerNotification.get("bigTitle"));

            } else {

                System.out.println(innerNotification.get("title"));

            }

            if (innerNotification.get("bigText") != null) {

                System.out.println(innerNotification.get("bigText"));

            } else {

                System.out.println(innerNotification.get("text"));

            }

        }

    }

}


34. How to make java 15 compatible with appium.

If you are using maven project then update the following in pom.xml


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

35. How to execute adb command via java code.

import java.net.MalformedURLException;

import java.net.URL;

import java.util.Arrays;

import java.util.List;

import java.util.Map;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.testng.Assert;

import org.testng.annotations.Test;

import com.google.common.collect.ImmutableMap;

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.remote.MobileCapabilityType;

public class ADBCommandViaScript {

  private static String ANDROID_PHOTO_PATH = "/mnt/sdcard/Pictures";

  @Test

  public void testArbitraryADBCommands() throws MalformedURLException {

     DesiredCapabilities capabilities = new DesiredCapabilities();

     capabilities.setCapability("platformName", "Android");

     capabilities.setCapability("deviceName", "Android Emulator");

     capabilities.setCapability("automationName", "UiAutomator2");

     capabilities.setCapability(MobileCapabilityType.VERSION, "10.0");

     capabilities.setCapability("noReset", "true");

     capabilities.setCapability("fullReset", "false");

     capabilities.setCapability("appPackage", "com.google.android.apps.photos");

     capabilities.setCapability("appActivity", ".home.HomeActivity");

     // Open the app.

     AndroidDriver driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities);

     try {

        List<String> removePicsArgs = Arrays.asList("-rf", ANDROID_PHOTO_PATH + "/*.*");

        Map<String, Object> removePicsCmd = ImmutableMap.of("command", "rm", "args", removePicsArgs);

        driver.executeScript("mobile: shell", removePicsCmd);

        List<String> lsArgs = Arrays.asList("/mnt/sdcard");

        Map<String, Object> lsCmd = ImmutableMap.of("command", "ls", "args", lsArgs);

        String lsOutput = (String) driver.executeScript("mobile: shell", lsCmd);

        System.out.println(lsOutput);

        Assert.assertEquals("", lsOutput);

     } finally {

        driver.quit();

     }

  }

}

36. How to get memory info during execution?

mport java.net.URL;

import java.util.HashMap;

import java.util.List;

import org.hamcrest.Matchers;

import org.junit.Assert;

import org.junit.Test;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.AndroidDriver;

public class AndroidMemoryInfo {

   private static int MEMORY_USAGE_WAIT = 30000;

      private static int MEMORY_CAPTURE_WAIT = 10;

      private static String PKG = "io.appium.android.apis";

      private static String PERF_TYPE = "memoryinfo";

      private static String PSS_TYPE = "totalPss";

 

  @Test

   public void testMemoryUsage() throws Exception {

    

       DesiredCapabilities capabilities = new DesiredCapabilities();

       capabilities.setCapability("platformName", "Android");

       capabilities.setCapability("deviceName", "Android Emulator");

       capabilities.setCapability("automationName", "UiAutomator2");

       //capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "io.appium.android.apis");

       AndroidDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);

       try {

           // get the usage at one point in time

           int totalPss1 = getMemoryInfo(driver).get(PSS_TYPE);

           // then get it again after waiting a while

           try { Thread.sleep(MEMORY_USAGE_WAIT); } catch (InterruptedException ign) {}

           int totalPss2 = getMemoryInfo(driver).get(PSS_TYPE);

           // finally, verify that we haven't increased usage more than 5%

           Assert.assertThat((double) totalPss2, Matchers.lessThan(totalPss1 * 1.05));

       } finally {

           driver.quit();

       }

   }

   private HashMap<String, Integer> getMemoryInfo(AndroidDriver driver) throws Exception {

       List<List<Object>> data = driver.getPerformanceData(PKG, PERF_TYPE, MEMORY_CAPTURE_WAIT);

       HashMap<String, Integer> readableData = new HashMap<>();

       for (int i = 0; i < data.get(0).size(); i++) {

           int val;

           if (data.get(1).get(i) == null) {

               val = 0;

           } else {

               val = Integer.parseInt((String) data.get(1).get(i));

           }

           readableData.put((String) data.get(0).get(i), val);

       }

       return readableData;

   }

}

37. How Can I Exchange Data Between My Test And The App I Am Testing?

Appium, actually the WebDriver specification, is not made for exchanging data with your app, it is made to automate it. For this reason, you will probably be surprised in finding data exchange not so easy. Actually it is not impossible to exchange data with your app , however it will require you to build more layers of testability.

38. What Data Exchange Is?

When I say "data exchange" I am not referring to scenarios like getting or setting the value of a textbox. I am also not referring to getting or setting the value of an element's attribute. All these things are easy to achieve in Appium as Selenium provides commands just for those. By "data exchange" I mean exchanging information hosted by complex objects stored in different parts of your webview-based app like the window object.
Consider when you dispatch and capture events, your app can possibly do many things and the ways data flows can be handled are many. Some objects might also have a state and the state machine behind some scenarios in your app can be large and articulated. For all these reasons you might experience problems when testing.

39. I Want To Run My Tests In A Multithreaded Environment, Any Problems With That?

Yes! You need some special care when using Appium in a multithreaded environment. The problem does not really rely on the fact of using threads in your tests: you can use them but you must ensure that no more than one test runs at the same time against the same Appium server. As I mentioned, Appium does not support multiple sessions, and unless you implemented an additional layer on top of it to handle this case, some tests might fail.

40. Mention What Are The Basic Requirements For Writing Appium Tests?

For writing Appium tests you require:

Driver Client: Appium drives mobile applications as though it were a user. Using a client library you write your Appium tests which wrap your test steps and send them to the Appium server over HTTP.

Appium Session: You have to first initialize a session, as such Appium test takes place in the session. Once the Automation is done for one session, it can be ended and wait for another session

Desired Capabilities: To initialize an Appium session you need to define certain parameters known as “desired capabilities” like PlatformName, PlatformVersion, Device Name and so on. It specifies the kind of automation one requires from the Appium server.

Driver Commands: You can write your test steps using a large and expressive vocabulary of commands.

41. List some issues Faced With Cross-Platform Testing.

Generally, the issue depends upon the different OS/device version. It might be that the same application is working on one OS while it might not work on another version. For example, we faced an issue that our application was working fine on iOS 6.x version devices but on tapping a few modules on iOS 5.x devices application crashes and the same happened with 2.3.5 Vs.

42. List out the most common problem that a tester faces while performing mobile testing in Cloud Computing.

  • Subscription model
  • High Costing
  • Lock-in
  • Internet connectivity issues
  • Immense consumption of time in image-based automation testing.
  •  Automation is restricted by the framework

43. Difference between Selenium and Appium.

Selenium is an open-source tool that allows automation for Web applications run in Browsers. Appium is used for automating mobile applications and web applications which run on mobile devices.

44. List some common Exceptions in Appium.

  • SessionNotFoundException – Thrown when Appium Connection is disconnected or session not established.
  • ElementNotFoundException – Thrown when you attempt to find an Element and then the element is not Found.
  • WebDriverException – Thrown when the Driver is not existent.

45. What would you prefer to test on real devices or use simulators/emulators.

It’s one of the most commonly asked Appium interview questions. You’ve to be little logical and practical while answering it. Don’t just simply answer “It would depend on what you need.”. Because it would be a layman answer which interview won’t expect from you. Rather you should explain it by example.

You can say something like that it’s always best to test on real devices. As it would allow you to catch errors that you may not detect otherwise. But you have to configure the device smartly with the Appium server so that it can detect the device. Sometimes the ADB, the Android debugger may disconnect from the device even if it remains plugged in. And it can cause your tests to fail. To handle such issues, you can write a module which resets the ADB after some time to re-connect the devices.

46. What are the probable errors you might see while working with Appium.

Following are the errors you might observe with Appium.

  • Error#1: Missing desired capabilities e.g. Device Name, PlatformName.
  • Error#2: Couldn’t locate ADB. You may have missed setting the <ANDROID_HOME> environment variable.
  • Error#3: Selenium exception <openqa.selenium.SessionNotCreatedException>. It indicates a failure in creating a new session.
  • Error#4: Failure in locating a DOM element or determining the XPath.

47. Difference between Emulator and Simulator.

Simulator: A simulator is used to simulate an environment with all of the software variables and configurations that will be present in the actual production environment of an application. Simulators do not try to replicate the actual hardware that will run the application in production. Simulators can be written in high-level programming languages because they merely construct software environments. For example, a car racing game application can be thought of as a simulator as it simulates a real car race.

Emulator: An emulator does try to replicate all of the hardware and software aspects of a real-world environment. In most cases, you'll need to develop an emulator in assembly language to accomplish this. Emulators might thus be thought of as occupying a midway ground between simulators and real-world gadgets. For example, a car simulator racing game can be thought of as an emulator. It provides the hardware aspects of car racing as well with the help of emulators.

Emulators replicate both hardware and software features, whereas simulators solely simulate environment features that may be adjusted or created using the software. Emulators aren't a replacement for real-device testing since they don't always do a good job of simulating the hardware and software of a production system. They simply allow you to create an environment that is more similar to that of a real device.

Emulators are somewhat slower as compared to simulators as emulators need to sense the movement of hardware devices, convert it into a digital signal, and then process them.

48. When should you use a simulator and when should you use an emulator?

Case when we should use a Simulator: Simulators are typically used in software testing situations where the goal is to ensure that the application functions as intended when interacting with external applications or environments.
For example, you could wish to see if an application can communicate data to another application. Because the actual hardware configuration is unlikely to have much of an impact on data transfers for your program, a simulated environment will usually suffice. Simulated testing environments are also useful for ensuring that an application's interface shows properly across a range of screen resolutions.

Case when we should use an Emulator: When you need to test how software interacts with underlying hardware or a combination of hardware and software, emulators come in handy.
For example, if we want to discover if a firmware update will cause issues with our software or not, we can find out with the help of an emulator. Alternatively, we could want to know how our program performs when run on multiple CPUs or with varying memory allocations. Emulators come in handy in these situations as well.

49. Explain the general responsibilities of a mobile application testing framework. Also explain the general structure of a mobile application testing framework.

Following are the general responsibilities of a mobile application testing framework:

  • Choosing a format for expressing expectations
  • Developing a means to connect to or control the test application
  • Performing the tests and reporting the results

The general structure of a mobile application testing framework consists of the following segments :

  • Application Package: This refers to the target application which needs to be run and tested.
  • Instrumentation TestRunner: A test case runner that executes test cases against the target application. It includes an SDK tool for creating tests as well as an API tool, such as MonkeyRunner, that gives APIs for designing a program that controls an Android device.
  • Test Package: Two classes, Test case classes, and Mock objects are included in the Test Package. The mock object contains mock data that will be used as sample input for test cases, while the test case classes contain test methods to run on the target application.

50. Differentiate between Appium and Robotium.

Robotium: Robotium is a testing framework for Android that automates test cases for native and hybrid apps. The developer can use Robotium to construct robust automatic Graphical User Interface (GUI) testing cases for Android applications. A developer might also design a functional, system, and acceptability test scenario, which would cover a wide range of Android activities.

Following are the differences between Appium and Robotium:-

  • Appium is a cross-platform testing tool that works on both iOS and Android devices. Robotium, on the other hand, is limited to Android.
  • Robotium only supports the Java programming language, but Appium supports a variety of languages.
  • The Appium tool does not require any application source code or libraries, whereas the Robotium tool does.
  • Appium can test native, web, and hybrid mobile apps, whereas Robotium can only test native and hybrid mobile apps.
  • Many frameworks, such as Selenium, are supported by Appium. Robotium, on the other hand, is incompatible with Selenium and many other frameworks.
  • You don't have to reinstall Appium every time you make a little modification. However, a simple change in Robotium code necessitates a complete rebuild.

51. Differentiate between open source tools, vendor tools and in house tools.

  • Open Source Tools: Open source tools are frameworks and apps that are free to use. Engineers construct this tool and give it free on the internet for other engineers, developers, or enthusiasts to develop and use, which is incredibly beneficial for aspiring developers.
  • Vendor Tools: Vendor tools are created by companies that have a license to utilize their tools and codes. Technical support is accessible via the internet for these tools.
  • In House Tools: In-house tools are the tools that a corporation develops for its own usage and self-development. They are never made available to the general population.

52. Do you think that automation testing can be a complete replacement for manual software testing?

No, automation testing cannot be a complete replacement for manual software testing. This is because the tools used are meant to execute tests once they are set up and proper automation requires as little human participation as feasible. As convenient as it is, it should not be used to replace manual testing; rather, it should be used for repetitive activities such as load testing, which requires thousands of virtual users. Engineers should not automate test scripts if they are only intended to run on a periodic basis, nor should they automate code reviews or bug testing for new software builds that may require human engagement to detect errors. To sum up, we can say that large-scale, repetitive jobs are better suited to automation.

53. How much time does Appium take to automate a test?

It depends on the scenario you are testing. If you are verifying multiple flows in a single method, it is likely to take more time. But it is always better to make the test cases precise and straightforward so that if any issue occurs in between your execution, you can have the recovery mechanism.

54. Mention the Parallel Testing approach in IOS using Appium?

Selenium is an open-source tool that allows automation for Web applications run in Browsers. Appium is used for automating mobile applications and web applications which run on mobile devices.

55. Difference between Selenium and Appium.

Appium has given an option to run iOS tests in parallel from Xcode version 9 and above. There are a couple of prerequisites we need to follow.

  1. “UDID” should be unique.
  2. “wdaLocalPort” should be unique
  3. derivedDataPath root should be unique for each driver instance.
  4. Sauce Labs gives an option to run iOS tests parallel. We have to upload our Appium test to sauce labs. After that, it will run in multiple iOS tests in parallel.

56. What are the selenium commands works with Appium?

Appium implements Selenium WebDriver. That’s why almost all the WebDriver commands work with Appium. Few examples are mentioned below:

  • Click() command for clicking/tapping the button/links.
  • sendKeys() command to send the value.
  • It supports java scripts commands.
  • Handles alerts.
  • It can switch between the context in web-views.

57. Difference between tap and Click.

This is how tap is defined in TouchAction class

/**

* Tap the center of an element.

*

* @param el element to tap.

* @return this TouchAction, for chaining.

*/

public TouchAction tap(WebElement el) {

ActionParameter action = new ActionParameter(“tap”, (HasIdentity) el);

parameterBuilder.add(action);

return this;

}

while click() can be called directly on WebElement.

you can use click without any issues, Tap () returns TouchAction and is useful in chaining further Action.

58. What are the different tools for debugging in Android and iPhone?

We verify the logs to debug the issues occur in the devices. For Android we can check Monitor, “adb logcat” or “dumpsys” . For the iPhone, we can use iPhone configuration utility.

59. How can you find bundle id in iOS?

  • ●Copy the .ipa file to your systems and change the extension to .zip file
    ●Now unzip the folder and search for iTunesMetadata.plist file
    ●Once you get the file, open it in an editor and search for softwareVersionBundleId. It will give you the bundle id.

60. How can you enable the wifi while the phone is in Airplane mode?

ConnectionStateBuilder connection =
new ConnectionStateBuilder();
driver.setConnection
(connection.withWiFiEnabled()
.build());));

61. How can you enable unicode keyboard?

We need add below desired capabilities:
desiredCapabilities.setCapability("unicodeKeyboard", true);

62. How can you copy-paste in Appium?

Well, no direct method is there to do it. However you can get the value using getText() or getAttributes() methods and pass the same value to the sendKeys().

63. How to uninstall the app?

//Uninstall the app

public void uninstallApp(String androidSDKToolpath, String deviceId, String pkg)

{

  try{

     Runtime.getRuntime().exec(androidSDKToolpath+"/adb -s"+ deviceId + "uninstall"+pkg);

  }

  catch (Exception e)

  {

     System.out.println(e);

  }

}

64. How to clear the app data in Android?

//Clear the app data from android

  public void clearAppData(String androidSDKToolpath, String deviceId, String app_package) throws IOException {

     //adb -s <deviceID> <package name>

     Runtime.getRuntime().exec(androidSDKToolpath+"/adb -s "+ deviceId +"  shell pm clear "+app_package);

  }

65. How will you handle failure cases in Appium?

It depends upon the scenarios. If any test cases get failed, we need to restore the app state in order to execute the  next test cases. You can do it either in @AfterMethod or using listeners.

66. How to make your pass percentage higher in Appium?

Automating app using Appium sometimes makes the scrips inconsistent. If you run the test cases for longer times or may be due to network issues you can face the inconsistency issue. To make the script more robust we can take the following approach.

  • Make the script simple. Don’t put all the assertions in one Method . Instead create multiple test methods. It will help to recover the app for failure scenarios.
  • Don’t create a big suite. Instead create a small suite and run multiple times. It saves the execution times and in case of failures you can run the rest failure scenarios.
  • Run only failure scenarios 2nd time. Make sure this script can run independently.

67. Retry log in scripts.

https://seleniumjava.com/2017/07/22/how-to-retry-automatically-selenium-tests/



Tags


You may also like

Groups attribute in TestNG 

Groups attribute in TestNG 
Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}