Category Archives: Testing

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!

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!

                 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!

There’s a lot going on behind the scenes on  websites. More specifically, Web servers and other Web applications constantly send and receive data from browsers and servers, and if servers and applications aren’t properly secured, that application data represents a tempting opportunity for attackers.

It is essential to be able to examine the data moving between the browser and the Web server.One way to do this is with a free local proxy tool, called Burp Suite.Which is a local proxy for viewing and intercepting of data,between browser and website visited.

Whenever,a link clicked on the website,the browser sends a request to the server and receives a response back.The whole process is done in backend and invisible to the user.Here comes the “local proxies” like “Burp” and other proxies,which sits on the client local machines.The Burp act as a middle man between the browser and web server.

Burp supports Http request,in order to support Https request we need to add the certificate to the browser.

Adding certificate to firefox browser :

Download the certificae from  burp

on the firefox browser,go to the options — Advanced — Certificates — View Ceritficate — and import the certificate

Before installing of Burp,Make sure,installed java firstly

Install the Burp on the local Machine

Configration of Burp is different for different browsers (firefox,chrome,IE,safari)

Configuration of  Burp for the firefox browser :

Install a add-on  “Foxyproxy”

Tap on the  “add new proxy” — Tap on “proxy details” tab — Select the “manual proxy configration” and add the “host address” of the burp suite  and on the “General” tab add the name

2016-10-03_1809

2016-10-03_1807

The host address of the burp suite is available in the burp editor under proxy tab — option

and make sure under options,the intercept client request and intercept server response should be selected

1

Now,hit a url in the browser,in the burp,now able to see the  traffic between the browser and website made.Not only does it monitor what’s going on, it also allows you to alter what is happening where the real power of Burp suite lies.

 

Introduction :

Selenium is a popular open-source web based automation tool.Selenium is a robust set of tools that supports rapid development of test automation for web-based applications. Selenium provides a rich set of testing functions specifically geared to the needs of testing of a web application. These operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior.

One of Selenium’s key features is the support for executing one’s tests on multiple browser platforms.

What is test Automation ?

In software testing,a special software to control the execution of tests and the comparison of actual outcome to predicted outcome

Why we need test Automation ?

  • It save Time
  • Improves accuracy
  • Test coverage
  • Help us in Frequent regression testing
  • Finding defects missed by manual testing

Languages that supports Selenium :

  • Java
  • C#
  • Ruby
  • Python
  • php
  • perl
  • Javascript

Automate your web application using python :

Installation :

— Install python on your machine

— Install pip

Command : $python get-pip.py

— Now,you can install selenium like this:

Command : $pip install selenium

Now all set,you can start your automation using Python :

Sample Code :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get(“http://www.google.co.in”)
driver.find_element_by_name(“q”).send_keys(“Selenium”)
driver.close()

Explanation :

1) from selenium import webdriver

The selenium.webdriver module provides all the WebDriver implementations

2) Firefox WebDriver is created

driver = webdriver.Firefox()

3) driver.get method will navigates the user to corresponding url

driver.get(“http://www.google.co.in”)

4) Next,locating the elements

driver.find_element_by_name(“q”).send_keys(“selenium”)

Here we are located the element by using name ,in addition to that Selenium provides the following methods to locate elements in a page:
find_element_by_id
find_element_by_name
find_element_by_xpath
find_element_by_link_text
find_element_by_partial_link_text
find_element_by_tag_name
find_element_by_class_name
find_element_by_css_selector

To find multiple elements (these methods will return a list):

find_elements_by_name
find_elements_by_xpath
find_elements_by_link_text
find_elements_by_partial_link_text
find_elements_by_tag_name
find_elements_by_class_name
find_elements_by_css_selector

5) Next we are sending keys, this is similar to entering keys using your keyboard. Special keys can be send using Keys class imported from selenium.webdriver.common.keys:

driver.find_element_by_name(“q”).send_keys(“selenium”)
6) Finally, the browser window is closed,you can use quit() method or close() method.

Quit will exit entire browser whereas close will close one tab
driver.close()
You can save the above file as Sample.py and run the test like below

$python Sample.py

Automate your gmail login  sample code :

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

def init_driver():
driver = webdriver.Firefox()
driver.implicitly_wait(30)
return driver

def Myclass(driver):
driver.get(“https://www.gmail.com/”)
driver.maximize_window()
driver.find_element_by_name(“Email”).send_keys(“Please Enter your emailId”)
driver.find_element_by_id(“next”).submit()
driver.find_element_by_name(“Passwd”).send_keys(“123456”)
driver.find_element_by_name(“signIn”).submit()

if __name__ == “__main__”:
driver = init_driver()
Myclass(driver)
driver.close()

Save this file with .py and execute

 

What is JMeter?

The Apache JMeter is pure java open source software, Designed to load test functional behavior and measure performance testing. You can use jmeter to analyze and measure the web application and variety of services.

Performance testing means testing a web application against heavy load, multiple and concurrent user traffic. JMeter originally is used for testing Web Application or FTP application. Nowadays, it is used for functional test, database server test etc.

Advantages :

  1. Open source license.
  2. Friendly GUI.
  3. Platform Independent.
  4. Full multi-threading framework.
  5. Visualize Test Result
  6. Easy Installation.
  7. Highly Extensible.
  8. Multiple testing strategy.
  9. Simulation.
  10. Support multi-protocol.

How JMeter works?

JMeter simulates a group of users sending request to server, and get statistics of server and generate test reports in different format( i.e, Tree, Graph, Table, etc… ).

How to install JMeter?

  1. Down and install Java.
    Because JMeter is pure java desktop application, it requires JVM6 or higher.
  2. Download and install JMeter
    The latest version of JMeter is Apache Jmeter 2.13.
  3. Launch JMeter
    apache-jmeter-2.13/bin/jmeter.bat to start jmeter in GUI Mode.

JMetre Elements :

  1. Thread Group
  2. Logic Controller
  3. Config Element
  4. Timer
  5. Pre Processor
  6. Post Processor
  7. Sampler
  8. Assertions
  9. Listener

How to write script using JMeter ?

1.Open Jmeter
2.Right click on Test Plan add Thread Group via Add—>Threads( Users )—->Thread Group.
3.Right click on Thread Group add HTTP Request via Add—->Sampler——>HTTP Request.
4.Right click on Thread Group add View Results Tree via Add—>Listener——>View Results Tree.

See the below screens

By default JMeter screen is like this see the below screen.

16.mainscreen

Add Thread Group:(Test Plan —> Add—>Threads( Users )—->Thread Group)

10.Threadgroup page

Here,
Number of Thread – Number of users or connections to your server application.
Ramp-Up Period – It defines how long it will take to get all threads running.
Loop Count – It defines number of time to execute the test.

Add HTTP Request :(Thread Group—>Add—->Sampler——>HTTP Request)

15.http

Server Name or IP : We have to enter the web server name. In this example server name is  accounts.google.com( http:// part is not written this is only the name of the server or its IP ).
Protocol : We will keep this blank, which means we want http as the protocol. By default it            takes http.
Path : Here path is blank.

Add View Results Tree : ( Thread Group—->Add—>Listener——>View Results Tree )

17.view results

Start Test :

  1. Run — > Start    or
  2. ctrl+R

The Result page is like this. See the below screens.

14.Response

 

13.Resuls Page

Introduction:

Android SDK is mainly used for developing Android applications and has some good features that come handy for testing the Android apps. For ex. DDMS (Dalvik Debug Monitor Server)is the main tool in Android SDK that is used for testing purpose. I’ll be covering the steps to install Android Studio and SDK for Windows and Mac.

Installation for Windows:

– Prerequisites for installing Android SDK:

  1. Java Development Kit (JDK) should be installed before you install the Android SDK. Ensure that you are using the latest version of JDK. If not, its better to update as minimum version required is 1.7.
  2. Add the environment variable JAVA_HOME :
    – Click on ‘Start’ >> Right click on ‘Computer’ and click on Properties.
    – Click on ‘Advance System Settings’ >> Environment Variables.
    – Click on New and add ‘JAVA_HOME’ variable and value will the path of the JDK installed.
  3. Also add the path of bin folder to the ‘Path’ variable Ex: C:\Program Files\Java\jdk1.8.0_71\bin.

– Installing Android Studio and SDK :

  1. Download and install Android Studio from the link >> http://developer.android.com/sdk/index.html.
  2. After installation go to the ‘SDK’ folder where the Android SDK is installed.
    – Click on ‘SDK Manager’.
  3. Ensure that the latest versions of ‘Android SDK Tools’ and ‘Android SDK Platform-tools’ are installed. If not, then Check the latest versions and install.
  4. Add the environment variable ANDROID_HOME :
    – Click on ‘Start’ >> Right click on ‘Computer’ and click on Properties.
    – Click on ‘Advance System Settings’ >> Environment Variables.
    – Click on New and add ‘ANDROID_HOME’ variable and value will the path of the SDK installed.
  5. Add the path of ‘Platform-tools’ and ‘Tools’ to the ‘Path’ variable.
    Example: D:\Android\sdk\platform-tools; D:\Android\sdk\tools
  6. Installation is done. Now open the CMD prompt and type >> adb and press Enter.
    – If the command is executed and list of adb commands are displayed then you are ready to use Android SDK.

Installation for Mac:

– Prerequisites for installing Android SDK:

  1. Java Development Kit (JDK) should be installed before you install the Android SDK. Ensure that you are using the latest version of JDK. If not, its better to update as minimum version required is 1.7.

– Installing Android Studio and SDK :

  1. Download and install Android Studio from the link >> http://developer.android.com/sdk/index.html.
  2. After installation go to the ‘SDK’ folder where the Android SDK is installed.
    – Click on ‘SDK Manager’.
  3. Ensure that the latest versions of ‘Android SDK Tools’ and ‘Android SDK Platform-tools’ are installed. If not, then Check the latest versions and install.
  4. Copy ‘Platform-Tools’ and ‘Tools’ path to Bash Profile. Generally you’ll find this under : /Users/”YOURUSER”/Library/Android/sdk
    – Open bash_profile using the below command:
    sudo open -a “TextEdit” ~/.bash_profile  OR use vi editor: sudo vi ~/.bash_profile
    – Add below paths:
    export PATH=/Users/”YOURUSER”/Library/Android/sdk/platform-tools:$PATH
    export PATH=/Users/”YOURUSER”/Library/Android/sdk/tools:$PATH
  5. restart terminal. (You can use —>>  source ~/.bash_profile).
  6. Installation is done. Now open the terminal and type >> adb and press Enter.
    – If the command is executed and list of adb commands are displayed then you are ready to use Android SDK.

Conclusion:

I have shared the steps to install Android SDK on Windows and Mac. We are now ready to use the Android SDK for either the development or Testing purpose. Thanks for reading this article. For more info please visit http://developer.android.com.