Friday 18 October 2019

Setting Appium Doctor , Java Home and Android home for Running appium

Setting Appium Doctor , Java Home and Android home for Running appium 


One of the biggest challenge that comes in Automating Mobile using Appium is its installation.
In this post I will try to layout step by step process to have minimal heckle to install and run Appium

We need two Basic thing to install and Run Appium.

Appium Doctor : to see Environment configurations are good for Appium.As pet their git page

Appium Doctor "Attempts to diagnose and fix common Node, iOS and Android configuration issues before starting Appium."

Installing Appium Doctor using below command
  • npm install appium-doctor -g
Then run below command to see respective OS configuration:
  • appium-doctor --android 
  • appium-doctor --iOS

 




Currently Since my system has all the right configuration everything is coming green.If you also have green tick it means configuration is good.


Setting Android Home Path and Java Home Path

- open .
~/.bash_profile

add below lines.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_SDK_HOME=/Users/saif.siddiqui/Library/Android/sdk
export ANDROID_HOME=/Users/saif.siddiqui/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export ANDROID_HOME="/opt/intallation-location/android-sdk"
Keep in mind to change my system name with yours wherever applicable.
See below highlighted image for clarity




After making the changes , Run source ~/.bash_profile in CMD prompt.

Similarly Open - 

~/.profile
add below lines:
export ANDROID_HOME=/Users/saif.siddiqui/Library/Android/sdk;export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Homeexport PATH=${JAVA_HOME}/bin:$PATH
Keep in mind to change my system name with yours wherever applicable.
See below highlighted image for clarity



After making the changes , Run source ~/.profile in CMD prompt.
Now Run :    appium-doctor --android 

If the configuration is good you will get all the green ticks.

Friday 21 June 2019

Migration Testing Scenario for Android and iOS





Migration Testing Scenario for Android and iOS

Migration testing is one of the important testings particularly for mobile applications where a single mistake can take 3 days to 7 days to fix, deploy, and roll the app again on production. If you have a large user base and real-time application like Flight booking or Hotel Booking we need to be cautious while doing the migration testing.

Why we do Migration testing?

Migration is being done on the new OS, tech stack, or DataBase.
Particularly I will be discussing the migration of mobile apps which may include all or none of the above situations.

Use Case of migration:

  1. To give users better performance, you don't want your million flight booking or hotel booking consumer to navigate to your competitor's site.
  2. Moving to the new tech stack from the obsolete one. Why would you like to drag the legacy technology when new technology can bring you peace of mind and ROI.
  3. Cost reduction of the maintenance of the application.Which may include the second point.
When the migration testing is done :

  1. Do you remember the blackberry devices, they use to have their own OS. Slowly they were not able to compete with the Android OS so before they finally moved to the Android OS they were allowing the android developers to port their Android Apk on blackberry os with the help of the wrapper library they wrote. Since the .apk file was wrapped for Blackberry and it was migrated on BB OS we need to do migration testing for the new OS.
  2. Currently, the Native apps are being replaced by React Native apps. This involves changes of tech stack apart from maintaining the DB of the user in the react native app which can affect different areas depending on the functionality of the app, the common one being login functionality.
  3. Migration testing of the new app over old app having new features and bug fixes, example the previous functionality allowed your user to login with Email. Now they have SSO like Google login and Facebook login. We need to verify that after these new features are implemented they are working fine on the new app once they are installed over the old app.

Test Cases:
  1. Install the new application and verify the migration.
  2. Install the old app over the new app and verify the migration.
  3. Install the new app and then the old app over it (Reverse migration for risk management).
  4. Login in the old app and install the new app.If authentication token are grasped automatically all user data should be preserved else if the user is log in again on the new app they after login user should see all the data.
  5. UI testing of the migrated app. Remember how Blackberry once allowed to port the Android app on their BB OS when they were not using android apps.I found many issues in my Indigo app at that time.
  6. Install the new app over the old app and play with it in flight mode i.e. internet is not connected with the app.
  7. Sometimes apple stores information like login in the key chain in the mobile. Now when the user login into the new app with his credential the key chain also passes some information which can lead to a crash. A perfect example is two authentications generated for the app in the same device for the same app.
  8. Verify the migration of old app over the new app for different OS versions and devices available



Friday 5 April 2019

Mobile Application Penetration Testing with MobSF

Subscribe to my youtube channel for more videos here:

What is MobSF?

As per their Github link :

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing framework capable of performing static, dynamic, and malware analysis. It can be used for effective and fast security analysis of Android, iOS, and Windows mobile applications and support both binaries (APK, IPA & APPX ) and zipped source code. MobSF can do dynamic application testing at runtime for Android apps and has Web API fuzzing capabilities powered by CapFuzz, a Web API specific security scanner. MobSF is designed to make your CI/CD or DevSecOps pipeline integration seamless.


How to Configure MobSF

If you have a docker installed, up and running just use below command :



docker pull opensecurity/mobile-security-framework-mobsf 

docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest 

















Running and doing static analysis of MobSF















- On running the above command MobSF will open in a browser on http://0.0.0.0:8000/ localhost.
- Drag and drop the APK/ipa file 
- MobSF will start doing the Static Analysis


Analyzing Report

Once the analysis of the file is complete you will get the result along with the potential issue that can be there in the app.
Dig out about them in detail and seek developers' help about how we can avoid these vulnerabilities.
















Conclusion

Quite a user friendly and easy to use interface will surely be going to make you go-go.
It can be easily integrated with most of the CI/CD available in the market.
You can also download the PDF and share it with the concerned stakeholder. 

Wednesday 13 February 2019

Running SonarQube locally with Docker: End to End


Running SonarQube with Docker in local Environment

docker pull sonarqube

$ docker run -d --name sonarqube -p 9000:9000 sonarqube

Once the installation is complete open sonarqube in Browser

http://localhost:9000


To see if the docker container is running in cmd  type 
docker container ls

ece799069a5f        sonarqube                                             "./bin/run.sh"           2 hours ago         Up 2 hours          0.0.0.0:9000->9000/tcp   reverent_goldwasser

By default you can login as admin with password admin, see authentication documentation. 
In the dashboard:
Create New Project
Enter Project Key>SetUp
Generate the token and Copy it
Select the Project Main Language,I have selected JavaScript
Download and unzip the Scanner for macOS

Configure the environment path for SonarQube in .bash profile by giving the path of the bin directory of SonarQube.It will be something like this:


Users/saif.siddiqui/Downloads/sonar-scanner-3/bin

To analyze a javascript project navigate to the project directory and run 

sonar-scanner \
  -Dsonar.projectKey=ProjectName
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=Token\
 -Dsonar.exlusion=.node_module

OR

Running through configuration file 

Create sonar-project.properties file in the project directory to be scanned using command:

touch sonar-project.properties

Add this configuration to run js,jsx file:

sonar.projectKey= ProjectName \

sonar.sourceEncoding=UTF-8

sonar.javascript.file.suffixes=.js,.jsx
sonar.sources=detox/e2e
sonar.host.url=http://localhost:9000
sonar.login=generatedtoken
sonar.exclusions=.node_module


In the above code,sonar.javascript.file.suffixes=.js,.jsx will run only js,.jsx file other files will be ignored.
-sonar.sources will run the files in detox/e2e
-sonar.exclusions will exclude the node_module folder
Go to the project directory and run Sonar-Scanner 




Navigate to the Sonarqube Dashboard and Refresh,you will see the result something like this:




Wednesday 16 January 2019

Emulator/Simulator or Real Devices,The Real Spartan ?


Emulator or Real Devices, which is better?




Why we should abstain ourself from using simulators/Emulators for Automation testing or Manual Testing altogether like:

- Testing on real devices is the best solution for uncovering bugs (regression included) and getting accurate results.

- Sometime things may seem to work on the simulator but may fail to work on Real Device,this can easily be deduced from the ongoing Native/RN task which quite often fails to work on OEM's.

-  Testing is being conducted in an environment that is not real and we are utilizing System hardware which cannot be compared to the Mobile Hardware.

- Simulators are not reliable since hardware features like GPS, camera, etc (though we only use  GPS) are either simulated or hardcoded in them and they are slow for automation purposes.




This Blog beautifully explains why we should `not use the simulator as the only source of the test environment`
https://mobilelabsinc.com/blog/simulators-vs-emulators

Thursday 20 December 2018

Unlock Secret folder in Jenkins in Mac - for initialAdminPassword







How to Unlock Secret folder in Jenkins in Mac - for initial admin password
    1. Navigate to /Users/Shared/Jenkins/Home/secrets/
    2. Right-click on the Secret folder to select "Get Info" option
    3. In the bottom select the Lock Icon and enter your password
    4. In the sharing and permission section choose read-only
    5. Move back to the Secret folder and choose InitialAdminPassword. (Again no permission to view it)
    6. Repeat step 2 to 5 to view InitialAdminPassword File.
    7. Open the file to be viewed in Textedit
    8. Copy the password and paste it on the webpage seeking a password.




Thursday 22 November 2018

Simple Appium Script to run on SauceLabs Server






Simple Appium Script to run on SauceLabs Server 

Create and account on Saucelabs and just replace the USERNAME and ACCESS_KEY with your credentials.

The process is clearly defined here:

https://wiki.saucelabs.com/display/DOCS/Best+Practice%3A+Use+Environment+Variables+for+Authentication+Credentials


package rough;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;

import java.net.MalformedURLException;
import java.net.URL;

public class SaucelabsSpike2 {

public static final String USERNAME = "xxxxxx";
public static final String ACCESS_KEY = "bfd66a9c-aa3f-445d-ab75-2416aa03c44a";
public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub";
public static AppiumDriver driver;

@BeforeClass
public void config() {
System.out.println("URL" + URL);

DesiredCapabilities capabilities = DesiredCapabilities.android();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Samsung Galaxy S4 Emulator");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("app", "http://saucelabs.com/example_files/ContactManager.apk");
capabilities.setCapability("browserName", "");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("appiumVersion", "1.5.3");

try {
driver = new AndroidDriver<>(new URL(URL), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@Test
public void sampleTest() {

driver.findElementById("com.example.android.contactmanager:id/showInvisible").click();

driver.findElementByAccessibilityId("Add Contact").click();
driver.findElementById("com.example.android.contactmanager:id/contactNameEditText").sendKeys("Test");
 driver.findElementByAccessibilityId("Save").click();
}

@AfterClass public void tearDown()
{
driver.quit();

}

}

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 ./


Thursday 18 October 2018

How to configure desired capabilities in Appium

What are desired Capabilities:

Desired capabilities are the set of information send to the Appium server whenever we are starting a new session.

They help us in defining the Version of the device,Version of the OS, the device which we are going to use,Application under test path and not limited too......


Below is the screenshot to create desired capabilities from Appium Desktop Interface 

















Here is the Sample example of the desired Capability for Appium
        

Usually I keep them in Config File

package utils;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import screens.android.HomePageAndroid;
import screens.android.LoginPageAndroid;
import screens.android.UserSettingAndroid;

public class CommonUtils {
DesiredCapabilities caps = new DesiredCapabilities();
public AppiumDriver<MobileElement> driver;
caps.setCapability("platformName", platformName);
        
caps.setCapability("deviceName", deviceName);
       
caps.setCapability("app", uri);
        
caps.setCapability("noReset", true);
        
URL remoteUrl = new URL("http://localhost:4723/wd/hub");
        
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"),   caps);
        
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

}
}

Wednesday 19 September 2018

Different terms/vocabularies/Tools used in automation Testing

Different terms/vocabularies/Tools used in automation Testing

Test runner — a tool that picks up files that contain unit tests, executes them and writes the test results to the console or log files. Mocha and Jasmine are two popular test runners used within the JavaScript community and TestNg/Junit in Java.
Assertion library — verifies the results of a test. Chai, Should, and Expect are examples of JavaScript assertion libraries and TestNg/Junit in Java.
Mocks — used in unit testing a component. A component under test has many dependencies. These dependencies are usually replaced by stubs or mocks. Stubs simulate a dependent object. Mocks offer an additional feature over stubs. With mocks, tests can be written to verify if the component under test has called the mocks as expected.
Mocking library — facilitates the usage of mocks in unit testing. Sinon and TestDouble are commonly used JavaScript mocking libraries and mockito in Java.

Other  Vocabs :
node.js - JS Environment
    Yarn - Package Manager
    npm - Package manager

Brew - Package manager

    OS level

Build Manager/task runner/Project manager

Java
 Gradle
 Maven
 Ant
 Ivy

Wednesday 25 July 2018

Setting Java_Home Environment on MAC OS X


Setting Java_Home Environment variable for Appium on MAC OS X


  • Open the Bash Profile to Edit it

  • In the bash_profile add the following line: "export JAVA_HOME=$(/usr/libexec/java_home)"
  • Save the changes
  • Open CMD and Type : $ source ~/.bash_profile
  • Verify if JAVA Home environment is set up on Mac by typing : $ echo $JAVA_HOME
  • If it's properly installed you will get something like below image:






.bash_profile should be like this:

export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_SDK_HOME=~/Library/Android/sdk 
export ANDROID_HOME=$HOME/Library/Android/sdk 
export PATH=${PATH}:$ANDROID_HOME:$ANDROID_SDK_HOME/emulator:$ANDROID_SDK_HOME/tools:$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/tools/bin






Sunday 1 July 2018

Difficult finding elements in React Native App?? Here is the Solution

React Native Developer Tools

Finding Elements in RN application,the best way I found while working on React Native automation tool "Detox" by Wix.

Working on the automation can sometime be frustrating,it gets worse when you are working on a POC on new software Automation tool.The same I faced while working on Detox RN mobile automation tool.

Getting to the point "react-devtools" can help us to find testID,label,text etc including props and state with ease to help us automate RN apps.It can be installed as a global package or for the particular project itself.Below are the steps to install it globally.

Steps to Install the react-devtools standalone app:
  • yarn global add react-devtools
  • Once installed run the following command in terminal "react-devtools".
  • From the in app developer menu click on "Toggle Inspector" and click on inspect to inspect element.
It will connect automatically for RN 0.43 or higher.

Tip:The shortcut to open toggle inspector on mac machine is "Command + D"




As soon as we inspect the components, the hierarchy is visible in the devtools and we can find the testID from it.

































Once we start inspecting the element the react native dev tools highlighted components 

Tuesday 10 April 2018

5 must step/approach to successful mobile testing strategy :

Subscribe to my youtube channel for more videos here:

5 must step/approach to successful mobile testing strategy :


Read about automation coding standards here: Avoid Mobile Automation Coding Pitfalls : Automation coding standards


Sunday 7 January 2018

Push Notification for Mobile Application

What is push notification?

Push Notification are messages that are sent by different app publisher's on different OS Android,iOS or any other OS.They can be sent even when the end user is not in the app.
Push Notification are of two type:

  • Hard Push Notification : It has only one option to select.Force upgrade notification is the best example of it.On tapping on the aforesaid notification user land's to respective playstore to update the Application.
  • Soft Push Notification : These are the messages having two options either perform that action or exit.

Note: The above are the Jargons used in my working environment and wording's may differ company to company.




How push notification works?

Operating system push notification service (OSPNS) acts as node to the App publisher to send the push notification to the end user.App publisher need to register themself on respective OS "OSPNS"
OSPNS for iOS is known as :Apple Push Notification's
OSPNS for Android is known as : Google Cloud to Device Messaging (C2DM)

IOS has notification center to control the them
In Android it can not be controlled at user level.

When push notification is useful?

The purpose of sending push notification is to increase :

  • User Engagement : Like "Saif,we are missing you.You are having 10 new messages"
  • Increasing ROI : Like "Book your flight now and get 10% off"
  • Giving valuable information : Like "Your Etihad Flight is delayed by 2 Hours"
  • Live Broadcast : Like "Cricket Score" and "Ronaldo hit a Goal just now"



Use Case of Push Notification?

When the End User hit's the push notification he should get desired information.

Test Cases for Push Notification?

  1. Push Notification should come when the app is in background.
  2. Push Notification should be received in the Language Sent.
  3. We should not get multiple push notification.
  4. Push notification should be sent to the target User only.
  5. It should be received in different time zones also.
  6. It should be visible on the notification Bar.
  7. Turn of the internet,send the push notification and turn on internet.Push notification should be received.

Wednesday 22 November 2017

Memory Leakage Testing for Mobile Applications

Memory Testing is the non functional testing of the Mobile Application which is performed to test how iOS,Android,Windows based application are consuming the RAM.


Following high level points are to be concerned:
  • The Application should work well at low memory also,it should not lag.
  • In case the memory is low and we want to install the application which require higher memory then we should get proper validation.
  • Verify that your application isn’t too heavy keeping in mind your competitor’s application.
  • There should be no memory leakage.
  • Monitor the use of Memory by the Application using Eclipse/*Android Studio (Android Monitor) which can also help in analyzing network, GPU and CPU usage  or any third party Memory Monitoring tool .

Tip: During and use and debugging of app, track the memory monitor. If the memory usage graph rises for your app and doesn’t fall even if put in background, it’s a memory leak.

*To read how we can use utilize Android Monitor in Android Studio click on the Link
Still from Android Monitor:
Image Source:Developer.Android.com

Sunday 15 October 2017

Mobile DeepLinking for Android and iOS Native Application


"MobileDeepLinking" How it can save your million Dollar and effort too!!


  1. Did you ever navigated from One Native Application to another Native Application without leaving the Application itself? You might not have really virtually felt it but you did. 
  2. Have you ever authenticated one Native Mobile  Application to open another Mobile application without exactly launching the Application? Ever used Tinder, authenticating your profile with Facebook?
  3. While reading any news,there was a tweet embedded into the Application and when you clicked on that you navigated to twitter?

If the answer to above question is yes, you have been using deep links!!

What are Deep Links:

Deep links are the URI uniform resource identifier that helps you to navigate on another Application with or without leaving the application like fb://profile

They are different from websites which have URL like www.tripsource.com

Deep linking’s for Mobiles are briefly bifurcated into two type's:

  • Deferred deep links: The Native Application is not yet installed but deep links invokes you to install the application or opens the mobile browser and then navigated to the deep link URI
  • Contextual deep link: The Native Application get’s launched when invoking the URI, remember Tinder Facebook relationship?

How can Deep Linking be useful?

I will be sharing here my real time experience with the best utilization of mobile deep linking in my previous project.

You have a native application for android, iOS, windows and responsive site. Now the requirement comes that we need to implement an MVP for hotels in a Travel Planner. It will require certain effort/reource to implement the MVP on android , iOS and responsive site platform but we don’t have that much time.
Any Solutions??

Now this is when Mobile Deep linking will come to our savior.

Now we will implement the MVP on responsive site and then access the MVP from responsive site in the native of the iOS and Android application.

                                 

Look’s simple,it’s not that simple when you will start testing it ;).

Use Cases for testing Mobile Deep Links

  1. UI issues and glitches on native applications Android and iOS
  2. Session handling, remember you are booking a Hotel and not 2 cent chocolate.
  3. Bit of security testing Authentication token/authorization handling in, may be a tech geek friend of your’s is spying you and tricks you to book hotel in his name by intercepting response.
  4. Localization Testing and Internationalization Testing, definitely I won’t like to view the website in any language that I don’t understand and my default language of native application was set to my native place.
  5. While accessing Mobile deeplinkings it’s recommended to use proper MobileDeepLinking URLS and iOS/Android libraries for the same.



Here are a few examples of deeplinks for popular apps on iOS:
Developer
Deeplink – e.g.
Purpose
Twitter
twitter://timeline
Opens the Twitter app and links to the user’s timeline
Facebook
fb://profile
Opens the Facebook app and links to the user’s profile
Yelp
yelp://
Opens the Yelp app (note: this example does not include any routing parameters)

Special thanks to TravelPort Digital and BCD Travel
Image Source: Google



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