Monday, May 8, 2017

Selenium vs Protractor

I started my IT journey started 6-7 years back having lots of hope & fears in mind. Though I was not in favour of IT & my father wanted me to be in administrative line, who used to tell me “Always your base should be strong enough to reconnoitre anything”. Family situation of mine was very bad, which forced me to put my steps in IT world keeping my father’s last words in my mind. Meanwhile I lost him in my early stage of job career & practically experienced how tough it is to lose someone who used to show the right direction.

In beginning stage of 2K the IT industry was matured enough to learn many things. Only thing I needed was proper direction. Started my career with .Net without knowing ABC of it. Still I was not happy & wanted something innovative as well as challenging. Someone suggested me why don’t you explore ‘Automation’, which will give you opportunity to get I touch with many languages (C#, VB Scripting, Java, Python, VBA, Java Scripting & many more). Which led me to start my career in Automation & DevOps world keeping “jack of all but master of none” on mind. Met great people/leaders in my journey, working with innovative people/leaders & hoping to meet many more in future. Fortunately got a chance to work under few great people when I was there in Malaysia who all did lots of great research in companies like Google, Motorola, Nokia, Intel : got to know how differently they do the things & which motivated me a lot. Sometimes got fed up with the internal politics which is obvious in IT, but one of my mentor advised me that “Establish good working relationships across generations, try to learn one best thing from the individuals you meet in your career since everyone is unique & never think about what others say as long as you are learning/grooming yourself”.

Fell in love with Automation & DevOps (Using great tools & languages) world after lots of success/failure R&Ds. Had very good connections whit the people working on same stuff & determined to capture my findings somewhere which will at least give beginning level directions. In Automation journey I found Selenium is the best tool to automate any web based applications. Recently got a chance to explore more on Protractor which is kind of wrapper over selenium to automate the applications developed using angular js. But still I have the last word of my father in my mind “Always your base should be strong enough to reconnoitre anything” since the IT industry is evolving, people gradually started using React.js, Night.js & future we never know !!! But the base is Selenium & will be..Here is my findings on "Selenium vs Protractor".

SELENIUM

· Works great even if its angular js website ,only we have to deal with synchronization issue,if you can handle then no disadvantage.
· Selenium is very reach in automation i.e its in the market for years and very much evolved and its api is almost stable.
· We can work with selenium in almost every popular languages(Java, C#, Python..).
· Matured enough to automate any kind of web application with proper strategy.

PROTRACTOR

· Marketed as angular based automation tool but its core is wrapper over webdriver js. Hence it do not uncovers any new vertical in browser automation.
· Yes it has certain advantage in case of angular specific locator strategy.since it provides more option to work with angualr directives.
· t's only available for only one client (language ) i.e for java script only.so to work with it you must know javascript.
· New in the market & not matured enough.

So I found Selenium is more flexible & matured enough to automate web based applications.


Saturday, April 8, 2017

Jenkins vs Bamboo

When it comes to DevOps people use many tools to streamline the process. I have used Jenkins extensively for CI\CD & DevOps activities. Recently started using Jenkins. Below are my findings & comparison metrics. It may vary from person to person who is in love with either Jenkins or Bamboo.

Jenkins :-  

Jenkins is an award winning application that monitors executions of repeated jobs, such as building a software project or jobs run by cron.
  1. Open source & free to use
  2. Not have a good UI, but customizable
  3. Has extensive community 
  4. Has tons of plugins to almost do anything we want
  5. It wont take too much effort/time to understand everything you need to know configure Jenkins for your builds
  6. Very good support for Test Automation 
  7. Easily we can integrate repositories like SVN,Git & CVS etc.
Bamboo :-

Bamboo is a commercial CI and delivery tool that ties automated builds, tests and releases together in single workflow. It works great alongside JIRA and Stash providing a fully traceable deployment pipeline.
  1. Commercial and have to purchase license 
  2. Has very good UI
  3. Major advantage when using Bamboo. If you are already using Atlassian products like Jira, Stash & Bitbucket etc
  4. Bamboo will integrate closely with other products in Atlassian ecosystem
  5. Not many plugins available
  6. Mainly we can integrate with Bitbucket since it's part of Atlassian ecosystem
  7. Very good support for Test Automation 
According to my R & D if you want a stand alone CI tool go for Jenkins. Any other findings or feedback is much appreciated.

Tuesday, March 28, 2017

Protractor :- E2E Framework

Automation: - People say this buzz word is the theft for current IT industry, but I find this as an opportunity to learn new tools & technologies. Since now days every IT Leader suggests two things with much illustrative examples. a. Learn & Unlearn b. Adapt to win. It can only happen, if people share their findings with others.


With this faster changing industry started my R&D to prepare E2E Automation Framework to accommodate “Angular JS” applications. Finally, 3 days’ effort paid off. Attaching the detailed architecture of the framework. Please let me know if you need any help from coding perspective.


Wednesday, March 1, 2017

Handle Browser Authentication PopUp

Many times we troubleshoot to encounter “Authentication Popups Window” during Web Application Automation or Web services automation using selenium.It’s pretty simple & tricky.


  •        Web Application:-  We can generally handle this with the below 2 approaches.
1.      Pass the username and password in URL itself
Example :-  Suppose Username :- Test, Password :- Test123 & URL :- http://www.test.com
Syntax :-  http://[Username]:[Password]@[URL]
    http://Test:Test123@www.test.com
2.      You can create an AutoIT Script and call script before opening the URL.


  •               Web Services:-  The approach is same as mentioned in section 1 of “Web Application”. Only  difference – Instead of URL we use end point in case of web services.

Saturday, February 25, 2017

Jenkins - Email Configuration (Example- Gmail)

We always struggle to configure our Email (either Personal/Office) with Jenkins. This article will help you to come out from that problem. I have taken "Gmail-Configuration" as example in this demonstration since Gmail is widely used.

First change the setting in Gmail to access less secure applications:- 
  • ·         Login to your Gmail account with valid credentials
  • ·         Navigate to "https://myaccount.google.com/security" url
  • ·         Enable "Allow less secure apps" option as shown in the below diagram 

Install Email-ext plugin:-
  • ·         Install Email-ext plugin at plug-in install page of Jenkins 

Configure System: - (Manage Jenkins > Configure System)
  • ·         Make sure you have logged into Jenkins as admin
  • ·         In Extended E-mail Notification section
  • ·         Enter your SMTP server name to “SMTP server”
    •  In case of Gmail – smtp.gmail.com
  • ·          Enter “Default user E-mail suffix
    • In case of Gmail – @gmail.com
  • ·         Click “Advanced”
  • ·         Click “Use SMTP Authentication”
  • ·         Enter required information(Gmail-Username & Password)
  • ·         Check “Test configuration by sending test e-mail”
  • ·         Click “Test configuration” to send test email
  • ·         Click “Save” in the bottom of the page

Configure a project to send email at every build:-
  • ·         Click “Add post-build action”
  • ·         Click “Editable Email Notification”
  • ·         Click “Advanced Settings…”
  • ·         Click “Add Trigger”
  • ·         Click “Always”
  • ·         Save 
Run your Test:-
  • ·         Click “Build Now” / “Build with Parameters” as per your requirement
  • ·         Check Console output and received email as shown below


XPath & Xpath Axes

XPath:- Xpath is used to locate a web element based on its XML path. XML stands for Extensible Mark-up Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags.

XPath Axes: - Plays a major role to handle dynamic web elements.

·         Axis details: -

AXIS Name
Result
ancestor
Selects all ancestors (parent, grandparent, etc.) of the current node
ancestor-or-self
Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself
attribute
Selects all attributes of the current node
child
Selects all children of the current node
descendant
Selects all descendants (children, grandchildren, etc.) of the current node
descendant-or-self
Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself
following
Selects everything in the document after the closing tag of the current node
following-sibling
Selects all siblings after the current node
namespace
Selects all namespace nodes of the current node
parent
Selects the parent of the current node
preceding
Selects all nodes that appear before the current node in the document, except ancestors, attribute nodes and namespace nodes
preceding-sibling
Selects all siblings before the current node
self
Selects the current node

·         Syntax -
axisname
::
nodetest
[predicate]
an axis
symbol
a node-test
zero or more predicates
Defines the tree-relationship between the selected nodes and the current node
Constant
Identifies a node within an axis
To further drill down the selected node-set

·         Examples of axis usage: -

Example
Result
child::book
Selects all book nodes that are children of the current node
attribute::lang
Selects the lang attribute of the current node
child::*
Selects all element children of the current node
attribute::*
Selects all attributes of the current node
child::text()
Selects all text node children of the current node
child::node()
Selects all children of the current node
descendant::book
Selects all book descendants of the current node
ancestor::book
Selects all book ancestors of the current node
ancestor-or-self::book
Selects all book ancestors of the current node - and the current as well if it is a book node
child::*/child::price
Selects all price grandchildren of the current node

·         Xpath example with Axis: -I have given few examples. Please try to use other axes with your own. If you are facing any issues, please let me know.

AXIS Names
XML
Xpath
ancestor
<root>
    <foo>
        <bar attr="xxx"></bar>
    </foo>
    <foo>
        <bar attr="val"></bar>
    </foo>
    <foo>
        <bar attr="zzz"></bar>
    </foo>
</root>
//*[ancestor::foo[bar[@attr="val"]]] or root/foo/bar[ancestor::foo[bar[@attr="val"]]]
ancestor-or-self
<root>
    <item key="a">
        <item key="b">
            <item key="c">
                <item key="d"/>
            </item>
        </item>
        <item key="e">
            <item key="f">
                <item key="g"/>
            </item>
        </item>
    </item>
</root>
ancestor-or-self::*[parent::item[@key='a']]
attribute
<Employees>
    <Employee id="3">
        <age>40</age>
        <name>Tom</name>
        <gender>Male</gender>
        <role>Manager</role>
    </Employee>
    <Employee id="4">
        <age>25</age>
        <name>Meghna</name>
        <gender>Female</gender>
        <role>Manager</role>
    </Employee>
</Employees>
//Employee[@id='4'] or /Employees/Employee[@id='4']
child
child::* selects all element children of the context node
child::text() selects all text node children of the context node
child::node() selects all the children of the context node, whatever their node type
descendant
<div id="books">
  <table>
    <tr><td class="title">Lord of the Rings</td><td class="author">JRR Tolkein</td></tr>
    <tr><td class="title">The Hitch-Hikers Guide to the Galaxy</td><td class="author">Douglas Adams</td></tr>
  </table>
</div>
//id('books')//td[@class='title']
or //id('books')//td[@class='title']









Topics to be covered

Tools & Technologies :-



Rough Mind map :-



BDD - Quick Start Guide

Behavior-driven development (BDD) is a software development methodology in which an application is specified and designed by describing how its behavior should appear to an outside observer. 

Principles of BDD: -
  • First define a test set for the unit/module
  • Make the test fail
  • Then implement the failed unit
  • Finally verify that the implementation of the unit makes the tests success
Concepts to Remember: -
  • Keywords:
    • Feature: List of scenarios.
    • Scenario: Business rule through list of steps with arguments.
    • Given: Some precondition step
    • When: Some key actions
    • Then: To observe outcomes or validation
    • And, But: To enumerate more Given, When, Then steps. But is mainly used for negative scenarios
    • Scenario Outline: List of steps for data-driven as an Examples and <placeholder>
    • Examples: Container for s table
    • Background: List of steps run before each of the scenarios
  • Symbols:
    • """ (Doc Strings)
    • | (Data Tables)
    • @ (Tags/Labels): To group Scenarios 
    • <> (placeholder)
    • "" (scenario parameter container)
    • # (Comments)

  • Feature File Definition Template: -
        @tag
          Feature: Title of your feature
                  I want to use this template for my feature file

          @tag1
          Scenario: Title of your scenario
          Given I want to write a step with precondition
             And some other precondition
          When I complete action
             And some other action
             And yet another action
          Then I validate the outcomes
          And check more outcomes

         @tag2
          Scenario Outline: Title of your scenario outline
          Given I want to write a step with <name>
          When I check for the <value> in step
          Then I verify the <status> in step

          Examples:
          | name    |value | status |
          | name1  |  5       | success|
          | name2    7   | Fail   |

  • Step Definition: -  When Cucumber executes a Step in a Scenario it will look for a matching Step Definition to execute. A Step Definition is a small piece of code with a pattern attached to it. The pattern is used to link the step definition to all the matching Steps, and the code is what Cucumber will execute when it sees a Gherkin Step.
    • Example: - Using Java & Cucumber


  • Runner File: - Mainly it's the driver to drive whole test execution.
    • Options: -
      • -g, --glue PATH -Where glue code (step definitions and hooks) is loaded from.
      • -f, --format FORMAT[:PATH_OR_URL]  How to format results. Goes to STDOUT unless PATH_OR_URL is specified. Built-in FORMAT types: junit, html, pretty, progress, json. FORMAT can also be a fully qualified class name.
      • -t, --tags TAG_EXPRESSION - Only run scenarios tagged with tags matching TAG_EXPRESSION.
      • -n, --name REGEXP - Only run scenarios whose names match REGEXP.
      •  -d, --[no-]-dry-run - Skip execution of glue code.
      • -m, --[no-]-monochrome - Don't colour terminal output.
      • -s, --[no-]-strict - Treat undefined and pending steps as errors.
      • --dotcucumber PATH_OR_URL-Where to write out runtime information. PATH_OR_URL can be a file system path or a URL
      • -v, --version - Print version.
      • -h, --help - You're looking at 
    • Example: - Using Java & Cucumber


Market Leading Tools: -
  • Cucumber: - https://cucumber.io/
  • JBehave: - http://jbehave.org/
  • SpecFlow:- http://specflow.org/
  • Serenity: - http://www.thucydides.info/#/
  • Spinach: - http://www.rubydoc.info/github/codegram/spinach/master