Showing posts with label Interview. Show all posts
Showing posts with label Interview. Show all posts

Wednesday, January 13, 2016

Appium : How to get the activity name of android application

How to get the activity name of android application


For mobile app automation, Appium requires app activity name (usually the first screen of your app when you tap on app to launch it ) in desired capabilities parameter . To get the app activity name which Appium can use while launching an app. here are the ways you can use to get the same  

Step 1 : using the aapt command.

To get the aapt.exe , you have to navigate to android sdk folder then build-tools and goto some api version . for example(specific to my machine) 
E:\Android\adt\sdk\build-tools\android-4.4W 

open command prompt and run the below command 
aapt dump badging

for example : Let's take whatsapp application
aapt dump badging E:\com.whatsapp.apk

output :
You can get the package name and launchable-activity with other details as highlighted in below :





























Step 2: using Appium UI console


Sunday, November 15, 2015

Android : How to change language of device using commandLine

How to change language of device using commandLine


Changing language in Android device on-the fly is needed when we are running or executing automation script in various languages.

To achieve language change of Android device, we have two ways:


You can watch a Youtube video OR follow the step by step procedure below





1> Using adb command 
 Below command can be run from command line , to change the language of device.
   
adb shell "setprop persist.sys.language fr; setprop persist.sys.country CA; 
setprop ctl.restart zygote"

** But this procedure is having one issue, your phone should be ROOTED to make adb command into effect.  

2> Using ADB Change Language APP installed on your device (link)

Steps: 
-
Install this APP on to your device.
-
Setup adb connection to your device (How to do - follow Link )
-
Android OS 4.2 onwards (tip: you can copy the command here and paste it to your command console):
adb shell pm grant net.sanapeli.adbchangelanguage android.permission.CHANGE_CONFIGURATION
- Language change example 1, Brazilian Portuguese:
adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language pt-rBR
- Language change example 2, Canadien French:
adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language fr -e country CA

To make your work easy , create a .bat file

@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@           Create .bat file                  @@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@

You can put the change language command in .bat file and can trigger it from your code.
Create a .bat file lets say : "changelang.bat" and paste below 3 line and save it.

cd /D 
adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language %1

exit




That's it.

Sunday, August 16, 2015

Java : Given two unsorted arrays ,write a program to remove duplicates and merge it into sorted order


package com.qahumor;

import java.util.Iterator;
import java.util.TreeSet;

/*@author : qahumor 
 * Given two Unsorted Arrays a1 and a2, 
 * Remove duplicates and merged both into sorted order  
 * 
 */

public class TwoUnsortedArrayMergedAndSorted {

 public static void main(String[] args) {
  
  int[] a1 = {1,2,3,49,6,77,8};
  int[] a2 = {3,67,77,3,10,54};
  int[] a3;
  
  TreeSet<Integer> ts = new TreeSet<Integer>();

  for(int i = 0 ; i < a1.length;i++){
   ts.add(a1[i]);
  }
  
  for(int j = 0 ; j < a2.length ; j++){
   ts.add(a2[j]);
  }
  
  Iterator<Integer> it = ts.iterator();
  a3 = new int[ts.size()];
  int k =0;
  while(it.hasNext()){
   a3[k] = it.next();
   k++;
  }
  
  
  for(int p = 0 ; p < a3.length ; p++){
   System.out.print(a3[p]+",");
  }
 }

}

JAVA : Program to check a given string, if rotated is a palindrome or not

/* * @author : P programs
    * Check if a given string becomes palindrome after rotation or not.
    * Exp : mmo , aaplaaeep , travel
    *
    *We can check for the count of each character in a string , If the total count of 2 chars are equal to                
        1 then the string can't be palindrome.
 */

package pprograms;

import java.util.HashMap;
import java.util.Scanner;


public class CheckStringRotationPalindrome {

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);

System.out.println("Enter a String ");
 
                String str = sc.next();
  HashMap<Character , Integer> hs = new HashMap<Character, Integer>();
int len = str.length();
int count = 0;

for(int i = 0 ; i < len ; i++ ){

if(hs.get(str.charAt(i))!=null){

hs.put(str.charAt(i), hs.get(str.charAt(i))+1);

}else{

hs.put(str.charAt(i), 1);

}
}

for(int i = 0 ; i < len ; i++ ){

if(hs.get(str.charAt(i))==1){
count ++;
if(count == 2){
break;
}
}
}

if(count ==1 ){
System.out.println("String can become palindrome after rotation");
}else{
System.out.println("String can't become palindrome even after rotation");
}
}
}

Sunday, August 2, 2015

Android : How to download .apk file from playstore


Here is the simple procedure to download the .apk file from playstore or from mobile device.

Procedure 1: Downloading from google playstore


Step1 : Browse URL https://play.google.com/store?hl=en
Step2 : Search for your app which you want to download, for example facebook.
Step3 : Select and click on the appropriate facebook app from list available.
Step4 : Copy the URL from address bar as it contains the app package name , see the pic below

Step5: Browse URL http://apps.evozi.com/apk-downloader/
Step6: Paste the copied URL in step4 to textbox as shown below.
Step7: Click on Generate Download link and click on download button as shown with highlighted button in red.

Sunday, June 7, 2015

Java : Program to find the minimum and maximum number in a given array.


/**
* Find the minimum and maximum number in a given array.
*
* Approach: we can pick an element from array and compare with the min and max value
*
*
*/

public class MinMaxNumber {

public static void main(String[] args) {

int arr[] = {1100,10,3,5,8,1,5,9,23,56,0,90,54};
int min,max;
min=max= arr[0];
for(int i =1 ; i<arr.length;i++){

if (min > arr[i]){ // comparing the number for min value
min= arr[i];
}

if(max < arr[i]){ // comparing the number for max value
max=arr[i];
}
}
System.out.println("Min value = " + min);
System.out.println("Max value = " + max);

}

}

/* output
Min value = 0
Max value = 1100

Tuesday, June 2, 2015

Java : Program to swap two number without using any arithmetic operator


import java.util.Scanner;

/*
*
* Swap two number without using any arithmetic operator like + , - etc
 * we can achieve the solution using the XOR operator
*/


public class SwapTwoNumberWithoutUsingOperator {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
System.out.println("Enter number A : ");
int a = sc.nextInt();
System.out.println("Enter number B : ");
int b = sc.nextInt();


System.out.println("Number before swapped A and B respectively --> " + a +" " + b);

a = a^b;
b = a^b;
a = a^b;

System.out.println("Number after swapped A and B respectively --> " + a +" " + b);


}

}

/* output
Enter number A :
10
Enter number B :
30
Number before swapped A and B respectively --> 10 30
Number after swapped A and B respectively --> 30 10

*/

Java : Program to find the sum of each row and each column of n x m of 2D Matrix


package jun2;

/*
* Find the sum of each row and each column of n x m of 2D Matrix
*
*/

public class SumOf2DMatrixRowsAndColumn {


public static void main(String[] args) {

int [][] twoDMatrix = {{ 20, 18, 23, 20, 16 },
{ 30, 20, 18, 21, 20 },
{ 16, 19, 16, 53, 24 },
{ 25, 24, 22, 24, 25 }
};
outputArray(twoDMatrix);
}

public static void outputArray(int[][] array) {
int sum= 0;
int rowSize = array.length;

int[] colSum =new int[array[0].length];
for (int i = 0; i < array.length; i++){
for (int j = 0; j < array[i].length; j++){
sum += array[i][j];
colSum[j] += array[i][j];
}
System.out.println("sum of rows "+ i +" = " + sum);
}
System.out.println(" ");
for(int k=0;k<colSum.length;k++){
System.out.println("sum of columns "+ k +" = " + colSum[k]);
}


}

}

/*output:

sum of rows 0 = 97
sum of rows 1 = 206
sum of rows 2 = 334
sum of rows 3 = 454

sum of columns 0 = 91
sum of columns 1 = 81
sum of columns 2 = 79
sum of columns 3 = 118
sum of columns 4 = 85

*/

Testing a New Product: Essential Information Software Testers Must Gather in the AI Era

    Learn what information software testers must gather before starting testing a new product, including AI, automation, compatibility, and ...