Selenium Tutorial

Selenium and Jenkins

Selenium features as below

 Selenium supports Cross Browser Testing. The Selenium tests can be run on multiple browsers and multiple machines and multiple Operating systems.

Supports several scripting languages like Java, Python, C#, and PHP.

Selenium uses Browser native commands. It locates and actions applied on UI elements,

Reporting are very easy and extensible.

TestNG quick summary:

 TestNG’s is Selenium + reporting features. It is easy to generate reports using Listeners and Reporters in TestNG

 Features of TestNG includes the following,

1)      Annotations – please refer my annotation blog Annotation – TestNG’s test case priority

2)      Supports parameterization/ data driven testing

3)      Test cases can be grouped and parallel testing is allowed.

Automaton testing using Cucumber – Behavior driven development (BDD)

Application behavior is the main focus on BDD. The requirements are written in English which gives more readability and understandability of the requirement.

So any roles in the company (Tester, developer, end user, and techno functional person) can read it and understand it. Also this will reduce the complication in terms of missing requirement or misrepresenting or misunderstanding requirements between different roles (Developer /tester / end user)

Gherkin is a business readable language – refer below for an example. Below feature file is integrated with Selenium and are having user stories as below.

Please refer below – “feature, Scenario, Given, When, And, Then “are the Keywords below to understand on how to write a feature file.

Selenium jenkins integration steps are as below:

Jenkin related steps:
1) start jenkins by running command in DOS prompt (detailed steps in here )
2) then make sure you are able to access url : localhost:8080
3) then you need to configure jenkins to run the selenium scripts – for that click on “Manage Jenkins”
4) then click on Configure systems
5) Find out the jdk files are installed (usually in C:\ program files … folder path) and copy paste the path in JDK section “JDK Installations” in ” Configure systems” which you are already in.
6) Give JDK name “JAVA_HOME” and provide Java path below in the next field.Selenium related steps:
3) Open eclipse IDE and start new Java project
4) make sure you added selenium jars (Selenium server standalone jar file which you can download add to new project) to support selenium framework for your automation testing.
5) then create a simple selenium script – make sure it is running and completing successfully in Eclipse.
6) Also create a xml file give a name “Xml1.xml”  Make sure Run “Xml1.xml” as “TestNG Suite” is working fine in Eclipse. Also notedown the xml file path in selenium project. create a lib folder in that and add all jar files which are required.Commmand prompt:
7) navigate to that project folder in command prompt and set all required classpath like bin and lib etc which are already in xml file folder in selenium project which you got from selenium project in eclipse.
8) then type command “Java org.testng.testNG Xml1.xml” which will display results in command prompt/DOS screen
9) now create a batch file “Batch1.bat” which contains the above command and also a command for compiling as e.g “java -cp bin;lib/* org.testng.testNG Xml1.xml”Jenkins setup to build and run the file:
10) in Jenkins, create a “new item” with selection of “Freestyle project”
11) then select “Advance options” and put the Selenium project home directory path in there.
12) the build trigger section, select Batch file execution option in there, then put the batch file name “Batch1.bat”
13) click and save the new item
14) click on “Build Now” and verify the “Console output”

How to configure Hub & Node machines for selenium parallel test execution
Configuring Hub machine

1) Start the command prompt/DOS prompt

2) Navigate to the folder location where the Selenium server jar file is kept.

3) Type java –jar selenium-server-standalone-[VERSION].jar –role hub

Note: [VERSION] is the one your downloaded version of selenium-server-standalone Jar file.

Your will see the below screen

Selenium Hub
Selenium Hub

4) Now type: http://localhost:4444 in browser

Your will see the below screen

5) Now type: http://localhost:4444/console in browser

You will see the below screen

Console

Configuring Node machines

Follow the same steps 1 to 2 in node machines

Then type,

Java –jar selenium-server-standalone-[VERSION].jar –role node –hub http://yourHUBmachineIP:4444/grid/register

Selenium Node

What is TestRunner in Cucumber

In order to link Cucumber with Selenium WebDriver, you need to start a Java project in eclipse IDE.

Then, add both Cucumber and Selenium jar files

Write test runner code and execute the same . Please refer BDD testing details on Selenium Cucumber

What is Pester

What is Pester Unit testing framework ?

Pester is a Unit testing framework for Powershell development. Pester can be downloaded from Github project and imported to Powershell as a module. 
Pester uses a bunch of keywords and assertions to evaluate the code quality.Developer could follow TDD approach which is Test driven Development where Developers first write the test based on requirement and then write the development code. Initially test fails and then development code correction done to make the unit test pass.

What is Findfailed exception in Sikuli

What is Sikul and Findfailed error in Sikuli ?

Sikuli is a GUI automation tool or library that uses images of the object to be automated from any given screen.
So these images are manually pre captured and stored in Sikuli automation framework if you are coding using Eclipse Java for Sikuli implementation.
After capturing the screen images, if you change windows screen resolution, Sikuli may give exceptions while execution and that error will be FindFailed exception. These exceptions will be displayed in error log or console of your IDE.

Sikuli Overview

Sikuli is a Desktop Automation library. This library “sikulixapi.jar” can be imported to any Java Selenium project to automate any desktop app or popup.
Sikuli uses “Screen” Class and it has lots of methods to support GUI interactions.E.g. Screen s = new Screen();s.click(“imageOfButton.png”);Note: Store imageOfButton.png at java root project folder.
Similarly you could do type, doubleClick, find etc methods provided by Screen class.
Sikuli automation is very simple and can be used to replace many day today tasks on outlook, windows software center installation. With that said sikuli can replace some of the robotic process automation done by many tools like Automation Anywhere, UiPath etc.

What is Sikuli Screen, Region, Pattern ?

Sikuli Screen is a class that has lots methods like click, double click, find etc to interact desktop GUI images.

Region class is to target a rectangular area location on GUI using x,y coordinates and width and height to locate the rectangular area.

Pattern class used for image level scanning support

Sikuli Architecture:

Sikuli scripts have Java library that takes care of mouse and keyboard actions using java.awt.Robot. Apart from this, Sikuli using OpenCV library which is C++ engine connected to Java via JNI. OpenCV is a computer Vision and machine learning library used for image recognition.

What is JNI

JNI is Java Native interface, it is java programming interface used to bridge the Java and other non java programming language like C, C++ application/programming frameworks

Summary about Jmeter and performance testing

Summary about Jmeter and performance testing

Jmeter recording

How to create Jmeter scripts?

Recording Jmeter scripts using Jmeter’s HTTP(S) Test Script recorder. There are two ways

1)      Manually adding scripts ( Test plan >> Tread Group >> Add>> Sampler >> HTTP Request )

2)      Recording using Jmeter’s HTTP(S) Test Script recorder

How to record Jmeter scripts using HTTP(S) Test Script recorder

Prior doing that we need to configure browser and learn about the Proxy setup

Jmeter to Application server communication need to be routed through a browser Proxy for this recording purpose. For that you may need to select the Browser (here we can use Firefox browser”

1)      Navigate to Firefox >> Tools >> options >> Advanced >> Network >> Settings

2)      Select Manual Proxy configuration >> HTTP Proxy = localhost & Port = 8080

How to run Jmeter in Jenkins

steps:

Jenkins setup and performance plugin setup:
1) copy performance plugin into Jenkin’s home directry before you start the test.
2) to do that – you can download the performance plugin “performance.hpi” from the site https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin
3) how to find the home directry of jenkins – to do that you can navigate to jenkins home page (localhost:8080) and then
4) click on “Manage Jenkins” and then click on “Configure system” the you will notice “Home directy” path in there.

Configure Jmeter and create a basic script in Jmeter:
5) download Jmeter Binary zip file from Jmeter site http://jmeter.apache.org/download_jmeter.cgi
6) unzip it and go to the “bin” directory of the Jmeter folder, wherre you will notice “user.properties” file.
7) open the file in notepad or notepad++ or any other text editor
8) add a line “jmeter.save.saveservice.output_format=xml” to that. Save and close the “user.properties” file
9) create a Jmeter script and make sure you can run it in non GUI mode i.e either in DOS mode or using shell scripts in MAC (note down the commands used in respective OS and it could be used in Jenkins job setup)
Note: for windows command line run, you can use the following commands

C:\[JMETER BIN directory]\jmeter.bat -Jjmeter.save.saveservice.output_format=xml -n -t C:\[JMETER script “.jmx” file] -l Jmeter_test_results.jtl

Note 1: For detailed topics on Jmeter scripts creation , please visit Jmeter , Jmeter recording 

setup Jenkin’s job to run Jmeter scripts
9) go to Jenkins home page (localhost:8080) and then click on “New Item” on “Freestyle project”
10) in the “New item” page, give some name in the item name field and go to below to section “Build” and add build step
11) add build step can be either a) “execute windows batch command” for windows or b) “Execute shell” for MAC
12) provide your command in there and save.
13) Click on “Build now” which would call the Jmeter (jmx) file and run the program
14) after the run, you can verify the Jenkins console to review the results.

Summary on Web testing and mobile apps

Summary on Web testing and mobile apps

 

What is the difference between Web Layer (Presentation Tier) vs Application Layer (Logic Tier) vs Database Layer (Data Tier)

  1. Presentation Layer is the interface to outside world e.g. web site.
  2. Application Layer is a framework to create the interface to the Web site or Presentation Tier
  3. Database Layer is the database and associated logic needed to query details.

Web Layer (Presentation Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains Apache web Server, Apache tomcat, Sun Java Web Server or MS Internet Information Services (IIS)

Application Layer (Logic Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains Apache tomcat, Red Hat JBoss, BEA Web Logic or IBM WebSphere app server

Database Layer (Data Tier)

Contains Virtual Machines and Physical Machines with OS can be Windows, UNIX or Linux

Contains SQL or Oracle

 

How to Use WhatsApp in a Web Browser?

1) Go to web.whatsapp.com in a web browser on a computer.
2) Then, on your iOS/Android/Windows mobile phone, open WhatsApp and press the Options on top right corner side
3) then press WhatsApp Web from the options.
4) use iOS/Android/Windows mobile phone to scan the QR code shown on the browser on your computer.

Headless web browsers

headless web browsers or programs are used to stimulate the browsers where there is no GUI is used for browser actions,

If you want to do browser operations or collect data from UI, there programming concepts will be used.

headless web browsers are listed as below,

HtmlUnit – No GUI browser for Java programmers and its pure java implementation, Open source programs. JavaScript support/DOM emulated. mainly used for used for testing purposes or to retrieve information from web sites.

Spynner – Programmatic web browsing module having AJAX support for Python

Ghost – it is a webkit web client written in python. it is WebKit-based. JavaScript supported and Open source.

Watir-webdriver- it an open source Ruby library for automating tests. Complete JAva script Support via Browsers

Twill – Allows users to browse the Web using command-line interface . Supports automated testing on web applications and Open source.

Awesomium –  is Chromium-based. and supports JavaScript and provides HTML-powered interfaces.

ZombieJS – Open source headless testing using Node.js. JavaScript support/emulated DOM.

SimpleBrowser – Open source web browser engine designed for automation tasks. It is built for .Net framework and No JavaScript support.

Sunset from Manhattan New York

Sunset from Manhattan New York. Sunrise and sunset are the beautiful time in a day from anywhere in the world.

Enjoy the Sunset near Central park, New York. Manhattan is one of the must see places in USA.

 

My google adsense story

My google adsense story 🙂

Google Adsense has been around more than 10 years from now. But I did not pay attention much until I read an article that said “top earners of Adsense ” which is monthly ‘makings’ is more than a $100k..

How did I start? About my background?

At that point of time, I was not aware of WordPress or domain services or even the difference between webhosting vs domain services. The main reason was my career was teaching and little bit of freelancing experience on digital marketing and functional testing.

YouTube is my teacher who upgraded me as a so called techie guy …I easily started WordPress development but the challenge was hosting the content from WordPress.

My failed attempts on web hosting and google Adsense approvals…  By that time I got a deal from godaddy and registered my domain. But hosting from WordPress was still challenging me.

My inability to successfully host WordPress site paid me off ! HTML 5, CSS, Node.JS, Java scripts …all technical stuffs got added to my skill set and I started Github hosting, My godaddy is linked to Github and finally my site www.shalimatech.com was live on around Oct 2016.

I started dreaming about the precious article I read “top earners of Adsense “. That dream had only 2 days life as I got email from google Adsense that my first request on Adsense program was rejected  saying “not enough content”

Okay, let me add more contents..btw site quality was poor like responsiveness, mobile and most modern browser support, along with contents which I wasn’t aware or did not pay attention to that as my primary focus was to make money   ..greedy me right. YouTube did not help me much on this ..I added 5 more cooking recipes and 10 more technical blogs on my site. Submitted with much more confidence. This time I did not have to wait much..google immediately informed me about their decision of rejection on my hard work.

My 3rd attempt. This time again google advised – Improve contents! I decided to fill contents ..added 50 cooking recipes and 20 technical blogs .. My confidence level was so high, I ignored about other technicalities that google looked for. Resulting 3rd rejection 

Bye to Bye to Github ..that is the first thing I did on the day I received rejection email from google.

Coming back to WordPress ! ..this time YouTube came to rescue..got a nice video on how to develop and host a website. I looked again for deals…this time web hosting deals. Found one hostgator offered 1 cent for 1st month.

Finally godaddy hostgator WordPress tie up went live on 2016 Christmas holidays season. .. I moved all Github contents that I had to My site www.shalimatech.com.  the site got new design, all new modern features..cudos to wordpress.com and wordpress.org.

Now google Adsense approval..this is going to be my 4th attempt..by this time my site was getting good views and user coverage mostly Europe and south American viewers..I need to analyze why Europe and South America ..why not others….May be my next research topic and subsequent blog!

I was confident and submitted My request for adsense approval..I did it this time ! Got email within 3hours from google adsense approving my site.

I was at New year party at friend’s time..welcoming 2017…it doubled my happiness. But I realized google still fully ready to give me the job!

I learned that google has 2 stages of approval and this was first stage. I again opened YouTube and other blog sites..while waiting for approval ..I continued adding blogs and I hit 60 technical blogs milestone..

I got Google’s blessing on Jan 6th  2017- my site is adsense ready and I started thinking about my precious blog  “top earners of adsense ” I read. And dream started again..

My First day earning .. I setup ad codes on 6th evening and to my surprise Jan 7th reports showed My first day earning $ 1.82!!! I was so happy and started sharing my success story to my friends..

Today is my second day…… I am frequently logging to my adsense account and checking reports as well as WordPress dashboard and  view statistics…

I hope my story will certainly inspire you ..this journey made a decent programmer and a “techie” …

I am going to post a blog on tips and tricks on how to get easily google approval ..WordPress site development tips and tips for domain registration and hosting soon.. Good luck…

TestNG quick summary for basic users

TestNG quick summary for basic users

 TestNG’s is Selenium plus reporting features. It is easy to generate reports using Listeners and Reporters in TestNG

 Features of TestNG includes the following,

1)      Annotations – please refer my annotation blogAnnotation – TestNG’s test case priority

2)      Supports parameterization/ data driven testing

3)      Test cases can be grouped and parallel testing is allowed.