Monday 18 August 2014

Installing TestNG Plugin for Eclipse

TestNG is a testing framework for the Java programming language inspired from JUnit and NUnit. The design goal of TestNG is to cover all categories of tests: unit, functional, end-to-end, integration, etc., with more powerful and easy-to-use functionalities.

Installing TestNG Plugin for Eclipse enable to run the test cases as TestNG Test directly from Eclipse.

Installing TestNG Plugin:

Go to Eclipse >> Eclipse Marketplace.

Enter the text "TestNG" in the Find field and press Enter.



Select the latest TestNG plugin listed and confirm the installation.



Wait for installation to complete. You may also click on OK button of a warning popup to continue.

Re-start the Eclipse. Now you are ready to use the TestNG.

Stay tuned to see more updates.

Facebook Page: https://www.facebook.com/crazzzygig

Configuring Maven With Eclipse

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Installing Maven in Eclipse is fairly simple. Follow the steps mentioned below:

Go to Eclipse >> Help >> Click Install New Software

Use this URL to get the latest stable build: http://download.eclipse.org/technology/m2e/releases/



Select Maven Integration for Eclipse and click Next.

Again Click Next to see installation details and Accept the License Agreement.



Now wait for the installation to complete:



If you get warning popup click OK to continue.

Now Re-start the Eclipse by clicking the 'Yes' button.



Now to check that Maven has successfully installed. Go to Eclipse Click:

File >> New >> Click Others.

Now expand the Maven folder and select Maven Project. Click Next and fill all the mandatory details to create a project. If you are able to create a maven project successfully, Maven has integrated successfully with Eclipse.

Stay tuned to see more updates. Please like/comment.

Suggestions are welcome.

Facebook Page: https://www.facebook.com/crazzzygig

Sunday 17 August 2014

Android Automation With Appium

In previous blogs we saw the process to setup Android Webdriver and Selendroid, which was used to automate Android Web Applications. The process to setup Appium is not much different, we require same set of tools except ‘Appium’ to start automating native, hybrid and mobile web applications.

Little introduction about Appium: Appium is an open source, cross platform test automation tool for mobile applications, hosted with GitHub. It supports Native, Hybrid and Mobile Web Applications. It is based on WebDriver JSON wire protocol.

Automation support for:
  1. iOS Mobile
  2. Android
  3. Firefox mobile OS
Test Modalities:
  1. Android
    1. Real Devices
    2. Emulators
    3. Native Browser
    4. Mobile Chrome
  2. iOS
    1. Real Devices
    2. Simulators
    3. Mobile Safari
Limitations:
  1. Android
  2. iOS
    • Need mac OSX 10.7+, lower versions not supported
Let’s start with the implementation, Following are the pre-requisites to start with:
  1. Java IDE (eg: Eclipse)
  2. Java Development Kit
  3. Maven Plugin for Eclipse (To create a maven project, you can create simple Java project)
  4. TestNG Plugin for Eclipse
  5. Android SDK
  6. Appium Server
Then, we need following configured:
  1. Environment Variables and Path Settings
    1. JAVA_HOME
    2. ANDROID_HOME
    3. MAVEN_HOME
  2. Android platform version 4.2+ must be installed.
Now, we will create a maven project.

Create a Maven project and open the pom.xml file. Add following artifacts to pom.xml and save the project:

image

Navigate to project >> Add a package >> Add a class:

In the below screen-shot as you can see I have created the instance of DesiredCapabilities and added some information to provide the Appium Server. We will see the relevance of each capability mentioned here.

image
  1. capabalities.setCapability("browserName", "") : It is used to tell the server which browser my script is going to use in case of mobile web automation, since we are automating here Native/Hybrid application so we will leave the value blank.
  2. capabalities.setCapability("deviceName", "emulator-5554") : It is used to tell the server on which device your script will run the automation. The value for device name can be achieved by running a command:     image
  3. capabalities.setCapability("platformVersion", "4.4") : It is used to tell the server which platform version is used.
  4. capabalities.setCapability("platformName", "Android") : It is used to tell the server which platform is used such as Android or iOS.
  5. capabalities.setCapability("appPackage", "com.SKSDroid.contactlistapp") : It is used to tell the package name for the application is being automated. To get the application package follow the steps:
    1. Create a folder named ‘app’ in the project created.
    2. Copy the application .apk file and paste in ‘app’ folder.
    3. Now navigate to : Windows >> Open Perspective >> Hierarchy View.
  6. capabalities.setCapability("appActivity", ".MainActivity") : It is used to tell the name of application activity on which will be the landing page for application when it will start.
  7. capabalities.setCapability("appWaitActivity", ".MainActivity") : It is used to tell the server to wait for the activity to appear before running the automation script.
As you can see in the below screen-shot of Hierarchy View, Device is listed with the opened application’s package name and active activity name which we have set in the capability. It will be updated as soon as you navigate to different activities.

image

Now finally it’s time to write test script. See the below code snippet in which we are just asserting a text of an element and clicking on it:

image

As you can see in the snippet we are using ID attribute to identify the element, so the question here is how to get the attributes of an element ? The answer is ‘UI Automator Viewer’. To start the UI Automator Viewer, go to tools directory of android sdk,open command prompt and write the command:

image

It will launch the UI Automator Viewer. Click on Device Screenshot button to generate the XML screenshot, and by hovering on the items you can see the attributes and values available for the element.

image

Once we are done with all above procedures, we will run the script. To run the script we first need to start the Appium Server. To start the Appium Server go to the downloaded folder ‘AppiumForWindows’ and double click on ‘Appium.exe’ to launch it. Click Start button to start the server on default ip address and port which is : 127.0.0.1:4723

image

Go to Eclipse and Run the script as ‘TestNG Test’. It will run the application on emulator and will perform the steps written in test script.

image

Please stay tuned to see more updates.

Facebook Page: https://www.facebook.com/crazzzygig