Friday 24 March 2017

Protractor : Locators for Protractor

 The heart of end-to-end tests for webpages is finding DOM elements, interacting with them, and getting information about the current state of your application. This post is an overview of how to locate and perform actions on DOM elements using Protractor.

Overview on locators

Protractor exports a global function element, which takes a Locator and will return an ElementFinder. This function finds a single element - if you need to manipulate multiple elements, use the element.all function.
The ElementFinder has a set of action methods, such as click(), getText(), and sendKeys. These are the core way to interact with an element and get information back from it.
A locator tells Protractor how to find a certain DOM element.
Protractor exports locator factories on the global by object.


Below are most frequently used properties in our projects:

Id: If an object is having id property then use below syntax:
element(by.id('Id property of your object'));
Classname : If an object is having class name as below  
Object class property is : classname =btn btn-primary
then write as  element(by.css(‘.btn.btn-primary’));
Function name: If an object is having an ng-click- function as below
<button ng-click="myFunction()" ng-show="flag">
    Submit
</button>
Then use this syntax to identify object: element(by.css('[ng-click="myFunction()"]'))
Text present on a button: If there is a text on an button then use below syntax
element(by.buttonText("Download AngularJS"));
Link text: If there is a link to identify we can use any of below given 2 options:
Option 1: element(by.linkText('Complete')).click()
Option 2: element(by.css('a[href*="Previous Versions"]')).click();

Table objects: If your applications is having an header row with multiple links and if it doesn’t have any specific properties as below screenshot

Then use below syntax:
by.xpath("//span[contains(@class,'MenuText')][contains(text(),Text on Link')]"));

Protractor command would be like this:
browser.driver.findElement(by.xpath("//span[contains(@class,'MenuText')][contains(text(), Text on Link ')]"));


Once protractor was installed you can find examples from the below location:
C:\Users\surendra\AppData\Roaming\npm\node_modules\protractor

We need to save this path to run our scripts on other browsers like IE





Thursday 23 March 2017

WebDriver: Setup for selenium webdriver


Files to download:

1) eclipse editor : https://www.eclipse.org/downloads/?
2)  jxl jar file: using this we can perform data driven testing: http://www.java2s.com/Code/Jar/j/Downloadjxljar.htm

3) junit .jar : to write junit test cases: https://sourceforge.net/projects/junit/
4) selenium java cleint drivers: http://selenium-release.storage.googleapis.com/index.html?path=2.48/
select below files to download:
·         Selenium JAVA 2.48.2 zip file

after download unzip that file >> it has 2 jar files and 1 lib folder inside that

this one contain all the selenium related commands in webdriver we were using different syntax so this one we no need to add>> it contains a libs folder in which multiple jar files are there even we need to add them to our project.

Configuring in Eclipse editor: 

1) create a new project in eclipse for writing test scripts in webdriver
Goto File >> new >> other >> expand java folder >> select java project >> click on next button >> give a valid name >> click on next button >> click on finish button

2) For this project now we need to add jar files
 right click on Project >> goto build path >> configure build path >> add external jar >> select the desired jar files(2 selenium java files and all the jars in the lib folder) and click on ok button >> ok button  >> automatically a new folder which is referenced library will be created to your project

** select java client drivers internally contains a libs folder in which there are few more jar files are there, add all the jar files from the libs folder **.



3) For this project create a package and for which create a new junit test


WebDriver: Introduction to Selenium WebDriver

what is webdriver??
webdriver is a tool for writing automated tests of websites. It will interact with the html of the application.
webdriver is an interface which contains set of abstract methods (unimplemented methods) which implemented by various classes like FirefoxDriver, IEdriver, chrome driver etc.
Browser supported:
·         Firfox
·         chrome
·         IE
·         safari
·         opera
·         invisible mode of execution: html unit driver
Architecture of webdriver:


·         For each and every selenium command written in binding(programming language) , a HTTP request is created and sent(through web driver API)  to the browser driver..
·         the browser driver uses a HTTP server for getting the http requests
·         the HTTP server determines the steps needed for implementing the selenium command they executed on the browser
·         the execution status is sent back to http server in webdriver
·         we no need to start selenium server to execute the test cases

Protractor : Installation of Protractor to your Machine

Protractor Installation:
***Use npm to install protractor globally***
·         Open the command prompt
·         Enter npm install g Protractor


·         click enter button
·         It will take couple of minutes to install
·         It will install two command line tools 1) protractor and 2) webdriver-manager.
·         Open command prompt and enter protractor --version to make sure it's working.
·         The webdriver-manager  is a helper tool to easily get an instance of a Selenium Server running.
What is the use of webdriver-manager:
The web driver manager is used for running the tests against the angular web application in a specific browser. After Protractor is installed, the web driver manager needs to be updated to the latest version
·         Open the command prompt and enter below command and click enter button
webdriver-manager update



·         Once Protractor is used to run any test, the web driver will automatically load and run the test in the relevant browser. To start the web driver manager, the following command needs to be executed from the command prompt.
·         Now start up a server with:
webdriver-manager start
·         The above will start up a Selenium Server and will output a bunch of info logs.
·          Your Protractor test will send requests to this server to control a local browser. Leave this server running.
·          You can see information about the status of the server at http://localhost:4444/wd/hub.

Protractor : Prerequisites to install Protractor in your machine

Prerequisites to install Protractor:
·         Install Node JS to your machine
1.      Navigate to below URL and click on V6.10.1 LTS


2.      Its going to download an MSI file

3.      Double click on the above downloaded file
4.      Click on RUN
5.      Click on Next >> I accept >> Next >> Next >> Next >> Install >> Finish
6.      ** Protractor README to make sure your version of Node.js is compatible with Protractor***
·         Open the command prompt and enter node –version it will show version on installed node JS
·         Download Editor to write the programs. you can use WebStorm or ideaIU editors
·         Download JDK latest version
·         Configure JAVA_HOME in environmental variables


Protractor : Introduction to PROTRACTOR tool

What is Protractor:
·         Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser
·         Protractor is built on top of WebDriverJS, which uses native events and browser-specific drivers to interact with your application as a user would.
·         Protractor supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any setup effort on your part.
·         Protractor also speeds up your testing as it avoids the need for a lot of sleeps and waits in your tests, as it optimizes sleep and wait times
·         It runs on real browsers and headless browser

History:
·         The first version of Protractor was released in July, 2013, when the framework was basically a prototype of a testing framework. However, Google, with the support of the testing community, is evolving the framework to follow the evolution of AngularJS and to meet the needs of the community that is using AngularJS.
·         The Protractor project is public in Github and you can follow the issues in the project, add issues you think are interesting, comment on issues opened by others, do a pull request to help the project, etc. Anyone interested in supporting the growth of the project is welcome!
Protractor is a framework for automation of functional tests, so its intention isn't to be the only way to test an AngularJS application, but to cover the acceptance criteria required by the user

Salient Features of Protractor:
·         It is built on the top of Selenium server.
·          Introduced new simple syntaxes to write tests.
·          The developer/tester can take advantage of Selenium grid to run multiple browsers.
·          A developer can use Jasmine or Mocha to write test suites.
As Protractor was built on top of Selenium WebDriver, so it contains every feature that is available in the Selenium WebDriver. Also, Protractor provides some new strategies and functions which are very useful to automate AngularJS applications.
It is also possible to use some drivers which implement WebDriver's wire protocol like ChromeDriver and GhostDriver, as Protractor runs on top of the Selenium. In the case of ChromeDriver it is possible to run tests without the Selenium Server. However to run tests using GhostDriver you need to use PhantomJS which uses GhostDriver to run tests in Headless mode.

What is Angular JS applications:
They are Web Applications which uses extended HTML's syntax to express web application components. It is mainly used for dynamic web applications. These applications use less and flexible code compared with normal Web Applications.

Why cant we use selenium webdriver for Angular Applications:
Angular applications has attributes like ng-repeater, ng-controller, ng-model.., etc. which are not included in Selenium locators due to which selenium is not able identify such objects. So Protractor on top of Selenium can handle those objects in any web application.

APPIUM : Introduction to APPIUM mobile automation tool

What Is Appium?
Appium is mobile web, native and hybrid software application test automation tool developed and supported by Sauce Labs . 
It is open-source software automation tool which is useful to automate android and IOS platform apps.

Most important thing is : Appium is “cross-platform” automation tool so you can write software automation tests against iOS and  Android (multiple platforms) using same API.
“cross-platform” enables you large amount of code reuse between iOS and Android test suites.
Appium support software test automation on emulator or simulator and physical mobile devices too.

Appium is developed on few key philosophy points :
1.      Should not have to recompile your app to automate it.
2.      Should not be locked into a specific language or framework. 
3.      Should be open source
4.      Should not reinvent the wheel when it comes to automation APIs.



How is Appium built?
Appium is basically an HTTP server written in Node.js® that creates and handles webdriver sessions.
Node.js® is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Appium architecture
As Appium is an HTTP server, its performs pretty much same as Selenium Webdriver server by
·         Receiving request/commands from client libraries*
·         Executes the command on the target devices/emulators
·         Responds with an HTTP response
Hence Appium works as a Client/Server architecture.
Appium Desired capabilities?
Desired Capabilities are sent by the Client to Server via JSON Objects by requesting the automation session we need.
These desired capabilities are found in the link below

Why Need Appium?
If you are mobile app software test engineer, Appium can makes your mobile app regression testing task easy. Specially for large mobile apps where continues apps are updating with new features and functionalities. Another main benefit of using appium for mobile app automation is : It supports bellow given multiple platforms and languages. Also you can use any testing framework.

Multiple Platforms Support
Appium support bellow given different platforms.
Android
IOS
FirefoxOS
Multiple Languages Support
Appium supports bellow given languages with the Selenium WebDriver API and language-specific client libraries.
Java
Objective-C
JavaScript with Node.js
PHP
Python
Ruby
C#
Clojure
Perl

Also there are other advantages like no source code is needed to test app as you can test it directly, also you can engage built in apps like camera, calendar etc in your test script if required.

Limitations Of Appium
There are few limitation in appium right now.
l  For Android, No Support for Android API level < 17.
l  Script execution is very slow on IOS platform.
l  Gestures support is limited.
l  No support for Toast messages
.
I think, this is enough to use any open source software automation testing tool in terms of usage flexibility.

Note : Appium supports only Android 17+ API level versions. Otherwise you need to use selendroid. You can find API level for your phone based on its version

Wednesday 22 March 2017

READY API : Introduction to Ready API

Hi All,

Hope you are doing good.

In this blog i would like to explain about Ready API.

Ready! API is a platform of tools to help you ensure high quality, performance, and security in your APIs. One download gives you access to the features of each tool within a unified experience.
·         Automate functional testing with SoapUI NG Pro to make sure that your APIs perform as expected in less time.
·         Use our compatible load testing tool, LoadUI NG Pro, to run load tests against your API functional tests.
·         Make sure the API you're shipping is safe using Secure Pro, to proactively test for invalid data, XML and JSON processing errors, and other common exploits.
·         Ensure fast and reliable integration for your external development teams and 3rd-party APIs using ServiceV Pro.

You can use this software in 14days trail period
In the next few points i would like to explain API Testing using this tool.
SoapUI NG Pro is your API functional testing tool:
·         Generate your test from your API's service description then use the Test Coverage feature to dynamically analyze your functional test coverage.
·         Use external data sources to react quickly when you need to simulate different user behavior without recreating your test case.
·         Speed your API testing with point-and-click property transfer and assertions.

Features about Soap UI NG Pro we will see in our next presentation