Category Archives: Android

Cloud Testing with SauceLabs:

We can set up Selenium Server on our local computer or we can use cloud grid system providers such asSauceLabs, Browserstack or TestingBot, etc. This kind of companies provides extensive grid on their servers. You can find all OS and all browser versions. In this post will see how to test with those services.

What is Sauce Labs?
SauceLabs is a grid in the cloud. We can run our tests on their cloud with different browsers and operating systems. You can also do manual testing. In order to do these, first, we should go saucelabs.com and register for free.

In the saucelabs dashboard: Automated Builds, Automated Tests, Manual Tests.

Let’s start how to Run a Selenium Tests with SauceLabs:

SauceLabs is great because they allow you to focus on testing instead of worrying about maintaining a bunch of environments against which your tests need to run. To get a small taste of this sauceomeness, let’s take a look at what it takes to get a Selenium script running in the SauceLabs Cloud.

Getting started:
1. First, we should go saucelabs.com and register for free.

Eclipse:
1. Create a Maven project and add selenium-related things (version, TestNG) in the pom.xml

In the above SampleSauceTest, We are providing “USER_NAME” and “ACCESS_KEY” to connect saucelabs.

How to get Access Key?

Sauce Labs accounts are protected by a username, a password, and an access key. We use our username and password to access Sauce Labs’ site, and we use our username and access key to allow our tests to access SuaceLabs’s Selenium servers

1. Go to User Settings
2. ACCESS_KEY – Copy and Paste it into the class.

We configure Remote WebDriver with DesiredCapabilities (it configures browser type, version, platform, etc.) and external server URL. Then, we can run our tests on the server which we configured for RemoteWebDriver.

NOTE: Run Script and Verify on Saucelabs

Overview of Sauce Labs Features:
1. Web Functional testing
2. Cross Browser testing
3. Mobile Web testing
4. Manual Testing
5. Automated Testing Platform
6. Real device coverage

Benefits of SauceLabs:
1. Running tests 24/7
2. Fewer human resources
3. Simultaneity
4. Record
5. Screenshots

Thanks for reading this article!

Testing web services was always a quite different. Doing functional testing of applications having UI is quite fun I must admit. You have pages, buttons, labels, text-box, images, etc. You know the underlying logic. Just enter the test data, click some buttons to call the underlying functions and voila, you are good to go.

Now, when you have web services to test, there is no UI involved (most of the time). You have to deal with XML files, XSDs, WSDLs, request and their responses and much more which for a functional tester might be overwhelming sometimes.

Main features:
Mocking the services
 →, With the help of SoapUI, we can easily mock the web services and test them thoroughly. We can use the WSDL file and it will auto-generate the services and all the methods it contains. So the hassle to create the services is now automated. It allows SOAP as well as REST services to mock.
Testing Security → SoapUI allow us to test the security features too. We can test the database by SQL injections to test the database vulnerability. Likewise, it allows us to test the stack overflow by bombing the XML files. We can also test the Cross Site Scripting by SoapUI.
Load Testing → One of the great features of SoapUI is to create the load test which can be seemingly integrated into LoadUI. We can set the SLA and verify it. It also lets you select the built-in load strategies like simple, fixed-rate etc.
Support wide variety of Technologies/Protocols → It supports a wide variety of protocols as well as technologies to make the life of a tester easier. The list comprises like SOAP, REST, Web/HTTP(s), JMS to name a few.
Automation Integration support → You can bundle your SoapUI test and integrate them with Maven, Hudson, Bamboo, JUnit, Ant etc without any hassle. You can even run your test with any task scheduler.
Powerful Analytics → Analytics gives us the ability to make the decisions and the real picture of AUT. SoapUI provides us various reports which are comprehensive in terms of the data yet not overwhelming for the user to understand. It also lets you to export the reports in any standard format and also gives us the option to customize them according to our needs.
Every report has some standard metrics which can be grouped as per need basis too.
Recording → SoapUI allows recording the all the data that is being sent and received from client and server. It even allows you to record the HTTP traffic. You can use the recorded messages to convert them into test cases.
Great Open Source Support → It allows anyone to develop the SoapUI plugins for their application. Widely used open source software like IntelliJ, Net Beans, Eclipse has developed the plugins for SoapUI and your test can be seemingly integrated with them.

In this post, let us see how can we create a Project in soapUI. To test web services, we have to have a project created in the soapUI tool.

The first step to create a project is to get access to the WSDL URL. This is an URL ending with?WSDL.

Before we create a project we have to understand the hierarchy in soapUI. The topmost level of the hierarchy is a Workspace. Workspace is a container to hold multiple projects. In other words, a workspace can have multiple projects. By default, there will be one workspace created by soapUI. You might create a new one to hold all your projects. Under Project, we can have multiple Test Suites. Under Test Suites, we can have multiple test cases and under test cases, we can have test steps.

Please follow next blog for creating a web service project in SoapUI tool.

Thanks for reading this article!

What is Jenkins?

Jenkins is an open source automation tool written in Java with plugins built for Continuous Integration purpose. Jenkins triggers a build for every change made in the source code repository, for example, Git repository.

Once the code is built it deploys it on the test server for testing. Concerned teams are constantly notified about build and test results. Finally, Jenkins deploys the build application on the production server.

Jenkins achieves Continuous Integration with the help of plugins. If you want to integrate a particular tool, you need to install the plugins for that tool. For example it, Maven 2 project, Amazon EC2, HTML publisher etc.

Advantages of Jenkins include:
  • It is an open source tool with great community support.
  • It is easy to install.
  • It has 1000+ plugins to ease your work. If a plugin does not exist, you can code it and share with the community.
  • It is free of cost.
  • It is built with Java and hence, it is portable to all the major platforms.
Now here we look into How to setup Jenkins for a Maven project. :
Step 1 – Starting Jenkins: which can be started via command line or web application server.
1.Download Jenkins Zip file and extract it(i have downloaded for windows as I am setting it up on windows7).
2.In cmd go to the path you have extracted Jenkins (eg.C:\Program Files (x86)\Jenkins)
3.To start the Jenkins, run the command jenkins.exe start
-To restart the Jenkins: Jenkins.exe  restart
-To stop the Jenkins: Jenkins.exe  stop
4.By default, it will open up on 8080 port as  localhost:8080 (make sure nothing else is running on port 8080)
Step 2 – Creating and configuring user on Jenkins
1.To create a user go to Manage Jenkins->Manage Users->Create User->Provide the required information
2.Go to Manage Jenkins->Configure Global Security
-Check Enable security
-In Security Realm, select Jenkins own user database and check Allow users to sign up
-In authorization, there are multiple options select as per requirement
-Save once done
Step 3 – Configuring System

1.Go to Manage Jenkins->Configure System
2.Configure JDK
-Give the JDK name
-JAVA_HOME : C:\Program Files\Java\jdk1.7.0_45
3.Maven configuration
-Give a maven name
-MAVEN_HOME : C:\apache-maven-3.2.5\apache-maven-3.2.5-bin\apache-maven-3.2.5
4.Global Maven_OPTS
–Xmx512m
–XX:MaxPermSize=128m
5.Save once done
Step 4 – Adding Plugins
1.Go to Manage Jenkins->Add Plugins
2.Install the plugins which are required, Eg. GIT client plugin: which Shared library plugin for
other Git related Jenkins plugins,  GIT plugin: This plugin integrates GIT with Jenkins etc.
Step 5 – Creating jobs
1.Go to New Items->Give a project name in “Item name” field->select Maven project->click OK
2.Now configure the job
-Provide the description
-In Source Code Management, there are options for CVS project, Git etc,  select the one which is required
-In Build Triggers, there are multiple options like “Build when a change is pushed to GitHub”,
“Poll SCM”, “Build whenever a SNAPSHOT dependency is built” etc, select the required one
-Give the path of your pom.xml file in Build Root POM
– Give “Goals and options“  take a use case where the requirement is to install the code then give ”clean install”
3.configure the job as in the screenshot and don’t forget to save
Step 6 – Run the build(job) from home page and output should be.
Thanks for reading this article!

How to send a mail through SMTP server using Java programming, it’s bulk process to send test cases(Screenshots, Description. text ) to many emails by manually so using JavaMail API it can be possible to send many users at a time.

This article will show you how to send a mail through SMTP server using java programming and follow below steps.

1. Create Maven Project
2. For sending the email using JavaMail API, you need to load the two jar files:

  • mail.jar
  • activation.jar

Download zip file

3. Project structure

MonitoringMail.java

TestConfig.java

TestMail.java

IMP: Before running the script we need to enable one option, follow below steps.

Note: This is only for FROM Mail address. Where we can send emails FROM and TO addresses.

Click on My account > Sign-in & security
Scroll down the page and then we should enable this ” Allow less secure apps: ON ” option otherwise, we will get exceptions.

One more point is will see this option only for new emails, not for old emails. it means email should be created recently.

Note: All set for running the code, right click on ” TestMail.java ” and run as JavaApplication.

You have successfully sent the mail.

Thanks for reading this article!

Remote debug live content on an Android device from your Windows, Mac, or Linux computer.

  1. Set up your Android device for remote debugging, and discover it from your development   machine.
  2. Inspect and debug live content on your Android device from your development machine.
  3.  Screen-cast content from your Android device onto a Dev Tools instance on your development machine.

Prerequisites:

  • USB Drivers installed if you are using Windows
  • A USB cable connected to your development machine
  • Android 4.0 or later
  • Chrome for Android installed on your Android Device
  • Android studio installed on your machine

Discovering your Android Devices:

  • On your Android device, Select Settings > Developer options > Enable USB DebuggingDeveloper Options is hidden by default on Android 4.2 or later.
  • To make it visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom

  • On you machine open chrome. You should be signed in one of your google accounts. Remote Debugging does not work in Incognito or Guest mode.
  • Open Developer tools.

  • In Developer Tools Click on   Go to More tools and Remote Devices

  • Clicking on Remote devices will open a small page below
  • Make Sure Discover USB Devices is enabled

  • In the right side you will see your Devices connected .If your device is showing up as Unknown, accept the Allow USB Debugging permission prompt on your Android device.
  • If you haven’t opened chrome on your Android device please open it.
  • In Remote devices under Devices tab click the tab that matches your device’s model.

  • Next to New Tab Enter a Url and click on open. The page opens New Tab on you Andorid device.
  • Clicking on Next to the Next to the Inspect tab will show the options for Reload, close and Focus

Inspect Elements:

  • Go to the Elements panel of your DevTools instance, and hover over an element to highlight it in the viewport of your Android device.
  • Click Select Element   on your DevTools instance, and the tap element on your Android device screen.

Note: The select Element  is disabled after the first touch, so you need to re-enable it every time you want to use this feature.

                 This article will show you how to run first automation script for testing android mobile app using appium server.

Before that,  we need to create a new maven project and update the pom file with below mentioned Selenium dependency. I am assuming you are familiar with Java project creation in Eclipse. Let me include a brief step by step guide to creating a project.

  • Open Eclipse ( I’m using : Neon.1a Release (4.6.1) )
  • Click on File > new > Maven Project

  • Click on Next > Click on Next >

Where Artifact Id is your project name, Group Id is your project path folder structure

  • Click on Finish

Once the project is created, copy the below dependencies in the pom.xml file.

Just we created the maven project with updated pom.xml file and we need to launch some tools.

  1. UiAutomator viewer  —  Used to find out android mobile app elements (id, classname, XPath).
  2. Appium server  — inform the appium server which kind of session we are interested in (via Desiredcapabilities ).
  3. Real Device / Emulator.

UiAutomator viewer: Which is used to find out android mobile app elements like id. Classname, XPath.

If you want to open the UiAutomator viewer, Go through this path

Ex: C:\Users\akumar\AppData\Local\Android\sdk\tools

  • Connect your android device to PC via USB cable
  • Enable your device in “Debugging mode”.   
  • Click on uiautomatorviewer > Click on this image button to refresh the device screen in Automator viewer.

  • Make sure before click on above image button, we need to launch our android mobile with our app (Which we want to test the app).

Ex; Here I’ m using the  “ dialer “ android app for making a call to someone

  • After that, we need to click on image button which I have marked as red color.

  • clicking on the each node gives you properties of UI element in the lower panel

By the above Image will show you how to take android mobile app elements ( id, text, classname ).

    • text attribute can be used as “name”
  • a resource-id attribute can be used as “id”
    • class attribute can be used as “className”
  • a content-desc attribute can be used as “AccessibilityId”

If you want XPath, you can write manual XPath using below syntax

Locating Android App Element By XPath:

  1. XPath using class and text attribute:

Ex: Take Calculator android app:

Syntax:   //class_name[@Attribute=’Value’]

driver.findElement(By.xpath(“//android.widget.Button[@text=’5′]”))

IMP :-  I will show you one example about Dialer app testing, just copy the code and paste it inside your java class.

Then Start appium server, below steps, show you how to start appium server on command prompt

  1. Navigate to C: -> Program Files -> Appium -> node_modules folder.

 Ex: C:\Program Files (x86)\Appium\node_modules

  1. Press and hold Ctrl + Shift Keys of keyboard and press mouse right click.
  2. Select “Open command Window here” from the context menu.
  3. It will open a command prompt with navigation to given node_modules folder path.
  4. Type command ” node appium ” In command prompt and press enter then appium server will start.

Note: All set for running our script, make sure before running our script we need to launch first appium server.

Thank you for reading this article!

              While launching an application using Appium, it is required to have the appPackage and appActivity to set the Desired Capabilities. Earlier it used to be a long and tedious task to get these details from the APK file but now there are multiple easy ways to find this information.

Example:

  1. Using APK info android app
  2. Using command prompt
  3. Using logcat In Command Prompt
  4. Using AndroidManifest.xml

Appium itself:

The best and the easiest way to find the appPackage and appActvity is from the Appium itself. Before that, you need to start your Appium client.

1) Start the Appium client. A Below mentioned window will display, Once you started the Appium client.

2) Click on the android icon marked above to open the configuration settings.

3) Check the Application Path check box.

4) Click on Choose button to locate your apk file, in this case, I have given it Flipkart.apk file.

Note: In case the correct information is not displayed in the Launch Activity field, click on the dropdown to look for the home.Home.Activity. Or if the information is not even there, try using the another way’s to find the information

Using APK info android app

Step 1: Just Download APK info app from AppStore

Once you downloaded the APK info app, Open the app

From there you will see android app’s which you are installed in your device, Just long press on the app which you want to get appPackage and appActivity.

Tap upon “Detailed Information”, there will see appPackage name and appActivity name

Ex:

appPackage name: com.facebook

appActivity name : com.facebook.katana.LogoutActivity

Note: We have so many activities on a mobile app, So make sure if you want to perform particular mobile interface(Screen) then choose that activity on APK info app.

Using command prompt

Get Package Name:

  1. Connect your android phone to PC and turn on USB debugging mode.
  2. Open Command prompt.
  3. Run command ” adb shell pm list packages -f “

  1. It will show you a list of apps(Which are installed in your device) with a package name.
  2. Find your app from the list. It will show you package name.

Using logcat In Command Prompt

  1. Connect your android phone to PC and turn on USB debugging mode.
  2. Open Command prompt.
  3. Run command  “ adb logcat “.

  1. Open app on the android phone. Immediately press CTRL + C in command prompt to stop logging in command prompt.
  2. Android phone’s latest activity will be logged in command prompt.
  3. If you see in the log, It will show you app launcher log.

If you want specific appActivity and appPackage on a particular mobile interface (mobile screen):

On command prompt, type below commands

  1. adb devices  — it show’s how many devices connected to your PC/laptop
  2. adb shell
  3.  dumpsys window windows | grep -E ‘mCurrentFocus|mFocusApp’ .

Then you will get appPackage and appActivity.

For example on command prompt

appPackage : com.android.mms

appActivity : com.android.mms.ui.ConversationList

Using AndroidManifest.xml

  1. Every .apk file contains AndroidManifest.XML file which contains android app’s package and activity name

Steps:

  1. .apk file for which you wants to get package and activity name.
  2. WinRAR should be installed in your PC.
  3. Right click on the .apk file of APK Info app(or any other .apk file for which you wants to know package and activity name).
  4. Select Open with -> WinRAR archive option from right click context menu.

5. It will open the .apk file in WinRAR window and you can see AndroidManifest.XML there as shown in bellow image.

6. Open AndroidManifest.xml file in notepad.

7. Now find keyword “p a c k a g e” In notepad. It will show you package name of your app.

8. Find keyword “a c t i v i t y” In notepad. It will show you activity name of your app.

I am sure the above different ways of finding APK information, one would definitely work successfully to you.

Thank you for reading this article!

This blog explains you about Capturing Photo/Video from your app and storing in a Custom Folder(your own Created folder in Gallery)..In the code you create your own folder in the Gallery..

The MainActivity class contains the Logic on Capturing and Storing the Photo / Video in your folder in Gallery

MainActivity.java

package com.example.kamranp.capturephotovideo;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.sql.Timestamp;

public class MainActivity extends AppCompatActivity {


    ImageView imageViewLoad;
    Button capturePhoto, captureVideo;
    VideoView videoViewLoad;

    private static final int CAPTURE_PHOTO = 2;
    static final int CAPTURE_VIDEO = 1;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        imageViewLoad = (ImageView) findViewById(R.id.imageView1);
        videoViewLoad = (VideoView) findViewById(R.id.videoView1);

        capturePhoto = (Button) findViewById(R.id.takephoto);
        captureVideo = (Button) findViewById(R.id.takevideo);

        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoViewLoad);
        videoViewLoad.setMediaController(mediaController);

        //Clicking on TakePhoto Button
        capturePhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAPTURE_PHOTO);

            }
        });

        //Clicking on TakeVideo Button
        captureVideo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
                    startActivityForResult(takeVideoIntent, CAPTURE_VIDEO);
                }
            }
        });

    }


    // The OnActivityResult helps to handle the functionality of the feature( After Capturing Photo/Video)
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {


        if (requestCode == CAPTURE_VIDEO && resultCode == Activity.RESULT_OK) {
            Uri videoUri = intent.getData();

            //Create folder in Gallery to store your Captured Images/Videos
            String appDirectoryName = "/FirstApp/";
            final File imageRoot = new File(Environment.getExternalStorageDirectory(), appDirectoryName);
            if (!imageRoot.exists()) {
                imageRoot.mkdir();
            }

            String dirName = Environment.getExternalStorageDirectory().getPath() + appDirectoryName;

            intent.putExtra(dirName, videoUri);


            Timestamp timestamp = new Timestamp(System.currentTimeMillis());
            File file = new File(dirName, "VID" + timestamp.toString() + ".mp4");
            try {
                AssetFileDescriptor videoAsset = getContentResolver().openAssetFileDescriptor(intent.getData(), "r");
                FileInputStream fis = videoAsset.createInputStream();
                FileOutputStream fOut = null;

                fOut = new FileOutputStream(file);

                byte[] buf = new byte[1024];
                int len;
                while ((len = fis.read(buf)) > 0) {
                    fOut.write(buf, 0, len);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            ContentValues values = new ContentValues();
            values.put("_data", file.getAbsolutePath());
            ContentResolver cr = getContentResolver();
            cr.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);

            // displays the captured Video on the app screen
            videoViewLoad.setVideoURI(videoUri);
            videoViewLoad.requestFocus();
            videoViewLoad.start();


        }
        if (requestCode == CAPTURE_PHOTO && resultCode == Activity.RESULT_OK) {


            String appDirectoryName = "/FirstApp/";

            //Create folder in Gallery to store your Captured Images/Videos
            final File imageRoot = new File(Environment.getExternalStorageDirectory(), appDirectoryName);
            if (!imageRoot.exists()) {
                imageRoot.mkdir();
            }

            String dirName = Environment.getExternalStorageDirectory().getPath() + appDirectoryName;
            Toast.makeText(this, dirName, Toast.LENGTH_LONG).show();

            Bitmap photo = (Bitmap) intent.getExtras().get("data");
            Timestamp timestamp = new Timestamp(System.currentTimeMillis());

            File file = new File(dirName, "IMG" + timestamp.toString() + ".PNG");
            FileOutputStream fOut = null;
            try {
                fOut = new FileOutputStream(file);
                photo.compress(Bitmap.CompressFormat.PNG, 100, fOut);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

            ContentValues values = new ContentValues();
            values.put("_data", file.getAbsolutePath());
            ContentResolver cr = getContentResolver();
            cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

            // displays the captured Photo on the app screen
            imageViewLoad.setImageBitmap(photo);

        }
    }
}

The activity_main.xml class contains the UI of the screen where you can click to capture the photo / Video and display it on the screen

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.kamranp.capturephotovideo.MainActivity">


    <VideoView
        android:id="@+id/videoView1"
        android:layout_width="180dp"
        android:layout_height="200dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="41dp" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="180dp"
        android:layout_height="200dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/videoView1"
        android:layout_toRightOf="@+id/videoView1"
        android:clickable="true" />

    <Button
        android:id="@+id/takevideo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/takephoto"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/takephoto"
        android:text="Take Video" />

    <Button
        android:id="@+id/takephoto"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/videoView1"
        android:layout_marginLeft="19dp"
        android:layout_marginStart="19dp"
        android:layout_marginTop="70dp"
        android:text="Take photo" />
</RelativeLayout>

In AndroidManifest.xml the required things to be added are ..


    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />

 

The AndroidManifest.xml looks like below..

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.kamranp.capturephotovideo">


    <uses-feature android:name="android.hardware.camera" android:required="true" />

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

The build.gradle (Module: app) required versions and dependencies and it looks like


build.gradle


apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.kamranp.capturephotovideo"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    testCompile 'junit:junit:4.12'
}


What is Genymotion emulator ?

Genymotion is a fast third-party emulator that can be used instead of the default Android emulator. In some cases, it’s as good as or better than testing on actual devices.

This article shows you how to create emulator through genymotion and How to install Google Play Services on Genymotion Step by Step.

1. Download and install genymotion emulator

First, we have to create account for downloading the genymotion emulator

1

Once you have created the account clicks on Download

3

After downloading you have to install genymotion on your machine

4

for the installation process, it is asking for us to install Virtual box 5.0.4 setup wizard, click on next button.

5

Launch the genymotion on your machine

6

How to create Samsung s5 emulator on genymotion. Click on add

7

Select which one you want for launching the emulator

8

<a href="http://blog.nbostech.com/wp-content/uploads/2016/11/91 achat viagra gratuit.png”>9

It is taking some time for downloading the emulator, Once it is downloaded click on finish button

10

Click on start button otherwise double click on emulator which we have downloaded now

11

It’s time to launch the Samsung emulator.

12

By default, your emulator doesn’t have Google play store for downloading the apps, So we need to install Google play store,

Here are some simple steps to do to make Google Services be available on Genymotion

Step 1: Install ARM Translation – The secret behind Genymotion’s fluidness is its ROM is compiled to x86 to match the most popular computer’s CPU Architecture

14

To install, download Genymotion-ARM-Translation_v1.1zip and then drop&drop the downloaded file to an opened Genymotion virtual device. After file transferring is done, there will be a confirmation dialog like below. Just simple click OK to flash it on a virtual device.

15

There will be an another dialog to let you know that the flashing process is done.

16

you need to reboot the device through command line like this:

adb reboot for the specific device

where

” 192.168.137.102:5555 ”   device name.

In case you accidentally close the virtual device, don’t be panic. You might need to relaunch for a few times before it can boot up.

Step 2: Install gapps – Before we go on to the next step, you need to download the flashable zip of gapps by your virtual device’s Android version: Here I am going to download the second

Android 5.0.x, Android 4.4.x, Android 4.3.x, Android 4.2.x, Android 4.1.x, Android 4.0.x, Android 2.3.3

17

And then drop&drop the downloaded file to a virtual device like previous and go through the flashing process.

18

Reboot the virtual device once again.

After the virtual device is booted up, you will notice that Google Play services have stopped problem will keep popping up like this:

Getting error like this

19

Better to restart the emulator or click on ” ok ”

All you need to do is be patient and login to Google Play Store and update all of the installed app.

20

21

Congratulations, Google Play Services are now available on your Genymotion virtual device.

22

Now verify your emulator version on your machine

Use ” adb devices” on your command prompt

13

You have successfully installed the genymotion emulator on your machine

Thank you for reading this article!

What is Appium ?

Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS and Android platforms. Native apps are those written using the iOS, Android, or Windows SDKs. Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android). Hybrid applications are web applications (or web pages) in the native browser, such as UIWebView in iOS and WebView in Android (not Safari or Chrome). Hybrid apps are developed using HTML, CSS, and Javascript.

Importantly, Appium is “cross-platform”: it allows you to write tests for multiple platforms (iOS, Android, Windows), using the same API. This enables code reuse between iOS, Android, and Windows test suites.

Environment setup for appium on windows 7.

Required Softwares:

  • java – JDK 1.8
  • Neon Eclipse
  • Apache maven
  • Android SDK
  • Emulator/Real device/
  • Appium server

Adding system variable:

  • JAVA_HOME
  • MVN_HOME
  • ANDROID_HOME

Step 1: Download and install java JDK 1.8 version

1.1 Accept license and click on below statement

1

1.2 Once installed the java, We should add java path into the system variables.

1.3 Create environment variable for JAVA_HOME. Follow the below step:

Navigate to System Properties ->Advanced System Setting->Environment Variable ->User Variable ->New ->Add path of java JDK folder

Ex: C:\Program Files\Java\jdk1.8.0_101

8

9

1.4 Adding java bin folder to System variable->Path->Edit

Ex: C:\Program Files\Java\jdk1.8.0_101\bin

12

3

1.5  Now verify the java installation using command prompt

Use java –version to verify java version and output comes like below.

4

Step 2: Download and install Eclipse

5

6

2.1 Unzip the folder and Run the Eclipse

Step 3: Download and install apache maven

7

3.1 Unzip the folder and save it on the local disk

3.2 Create environment variable for MAVEN_HOME. Follow the below step:

Navigate to System Properties ->Advanced System Setting->Environment Variable ->User Variable ->New ->Add path of Maven folder

Ex: C:\Users\akumar\Downloads\apache-maven-3.3.9

10

11

3.3  Adding maven bin folder to System variable->Path->Edit

Ex: C:\Users\akumar\Downloads\apache-maven-3.3.9\bin

13

3.4 Now verify the mvn installation using command prompt

Use mvn –version to verify maven version and output comes like below.

14

Step 4: Download and install Android SDK

4.1 Create environment variable for Android_HOME. Follow the below step:

Navigate to System Properties ->Advanced System Setting->Environment Variable ->User Variable ->New ->Add SDK manager path
SDK manager path :
C:\Users\akumar\AppData\Local\Android\sdk

15

4.2  Adding SDK Platform tools to System variable->Path->Edit

Ex: C:\Users\akumar\AppData\Local\Android\sdk\platform-tools

16

Step 5: Emulator/ Real device

When building an Android app, it’s important that you always test your application on a real device before releasing it to users. … You can use any Android-powered device as an environment for running, debugging, and testing your applications. So We can use two types of devices like Emulator/Real device.

Real device Testing: If you want to test one android app from your real device, follow the steps.

For test to run on devices, we need to make sure

  • Connect your real device to computer via USB cable 
  • USB Debugging is enabled
  • ADB lists your devices into the connected devices

Enabling USB Debugging:

By default, Android devices do not have USB Debugging enabled, these are under Developer Options. To turn them on,

  • Navigate to Settings app on phone
  • Scroll down and click on the Developer Options
  • Turn on the Developer Options and click the USB Debugging.

DevOptions

USBDebug

Some devices do not have “Developer Options” and hence the way to enable Debugging mode is to launch the Settings screen. Once done, tap “About Phone” and then scroll to the bottom and tap on “Build Number” 7 times (Yes 7 times)!

Once done, you will now be able to enable/disable it whenever you desire by going to

Once the above setups are done, launch Terminal (or Command Prompt) and type in

Actually, my device name is MOTO E (2nd generation).

30

Note:  ” Once you fix to test on real device You must install your real device drivers on your computer. Otherwise, your real device not connected with ADB devices.

Ex: My real device name is Motorola , So I need to install Motorola drivers

Emulator Testing : It is a virtual device but not the real phone but software which gives same functionality as the real phone (except few functionality like the camera). So we need to create the emulator for testing the apps.

Creation of Emulator: Before going to create Emulator , We need to add some properties to the SDK Manager

Open the SDK manager , Follow the below steps.

1. You have to mark below contents

  • Tools
  • Android version, which version you want
  • Extras

And install those packages

20

5.1 After installation of all packages go through this path

5.2 Click on AVD Manager

17

5.3 We need to Create Emulator( means Virtual device) tap upon create

18

5.4 Give the properties of your virtual device

21

22

 

 

 

 

 

 

 

5.5 Start your emulator and launch

23

24

5.6  Getting error while launching AVD with AMD processor

Solution: Make sure you have installed HAXM installer on your SDK Manager.

25

5.7 Finally getting the Emulator

26

5.8 Now verify your emulator is working or not through command prompt

Use ” adb devices ” to verify emulator and output is like below

29

Note: Using Genymotion emulator instead of AVD emulator

Since the performance of Android AVD emulator is quite low, especially not using the “host GPU”, so it’s better for us to use Genymotion, which is a faster Android emulator, based on VirtualBox.

Please follow the link for installation of VirtualBox and Genymotion.

Step 6: Download and install Appium

6.1 Unzip the folder and Install

27

6.2 Run the appium server

28

You have successfully setup the appium server with windows 7.

Thank you for reading this article!