Selenium tutorials

Selenium Tutorials 

Selenium and Jenkins

Protractor 

RobotFramework

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 blogAnnotation – 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

How to configure Sonarqube Jenkins integration

How to configure sonarqube in jenkins?

SonarQube is code quality checker and that can be integrated to Jenkins workflow to deliver continuous inspection.
Configuration steps as follows:SonarQube:1. Do a SonarQube docker image pull from docker hub 2. Then use docker run command to run the image to build SonarQube container.(Assumption JDK is already setup on the machine) if not , we need to docker containerized JDK.3. Now that step 2 allows us to run the SonarQube as a standalone server under localhost port 9000. (Type localhost:9000 on browser)4.login to SonarQube web app using admin as user I’d and admin as password.5. The go to Admin tab , Market place of SonarQube and install the plugins you wanted (SonarPython, Java, Groovy etc)6. You may need to restart SonarQube app after applying plugin installation.
Jenkins integration with Sonar1. Now that Sonar Server is ready, you may need to integrate Jenkins with Sonar.2. Login on to Jenkins, and go to Manage plugin section to install Sonar plugin.3. After restarting Jenkins, go the Configure system in Manage Jenkins section.4. Enable injection of Sonarserver,  add Sonar server auth token etc.
Now, Enable Analysis with Sonar scanner by defining the SonarQube server on Global configuration Then configure Jenkins build

What is contract testing

What is contract testing?

Contract testing is famous in microservices world. When we consider less numbers of microservices,  then contract testing is not so necessary.However when you look at the Amazon or Netflix microservices mesh, it is countless. Such cases it is extremely difficult for developer or tester to maintain unit/automation test suite as per the microservices development chnages.
Contract testing is the best possible solution currently offered for this situation. In contract testing, a mocked service is created to represent the provider.  There are commercial or opensource tools available to stimulate this. In short, contract is set of predefined requests and responses created by automation or developer team to do their testing.

How to read pdf content in java for automation project

How to read pdf content in java?

Apache PDFBox and FontBox jar available can be useful here. Add these two libraries to your Maven Pom.xml or build.gradle dependencies.
Then write java code to parse your PDF files to create POJOs.
What is POJO in javaPOJO stands for Plain java object and it has not restrictions or class path dependency.

What is Ansible molecule

What is Ansible Molecule and how to install Ansible Molecule ?

Testing your Ansible roles with Molecule: Ansible molecule project is helpful for Ansible roles development and testing. Ansible molecule have been great help for developing ansible testing framework and scenarios.

How to install Molecule?

python3 -m pip install –user “molecule[lint]”

molecule docker image is also available and is a good alternative way to implement ansible molecule.

Ansible molecule Anatomy:

Below are the Anatomy of Ansible molecule,

dependency:

name: this can be galaxy or Shell or Gilt

driver:

name: this can be docker, cloud like Azure, EC2, DigitalOcean etc

linit:

name: this can lint the program. For example ‘yamllint’ for yml playbook files.

platform: this configures driver specific platforms, populates hosts, handle interactions

name:

provisioner: this configures ansible playbooks run.

name: ansible

lint:

name: ansible-lint

verifier: this configures what to run for tests.

name: ansible

lint:

name: ansible-lint

scenario: this configures how test scenario runs…

test_sequence:

-lint

-create

-cleanup

-distroy

-syntax etc

Jenkins job vs pipeline

What is Jenkins jobs and Jenkins pipeline ?

Jenkins jobs and Jenkins pipeline are essentially same, however pipeline is more staged flow of jobs. For Jenkins pipeline, Jenkinsfile is used.
What is Jenkinsfile?Jenkinsfile is a text file placed in the root project directory. The Jenkinsfile has multiple stages like build, unit test, sonar test, functional,  regression, integration,  performance testing, deployment etc.

What is HtmlUnitDriver in Selenium

What is HtmlUnitDriver in Selenium ?

When I wanted to run my automation scripts on CI/CD pipeline back in 2017, I was experimenting the headless browsers using HtmlUnitDriver
Now Chrome headless picked up popularity over HtmlUnitDriver as switching from GUI browser selenium code to Chrome headless is very easy unlike HtmlUnitDriver.
Selenium automation utilized HtmlUnitDriver when it needs a non GUI mode executions on jenkins server when there is no browser installed on it or no support from docker containers.

What is PhantomJs used for

What is PhantomJs used for ?

When I wanted to run my automation scripts on CI/CD pipeline back in 2017, I was experimenting the headless browsers starting with PhantomJs.
Now Phantomjs is a discontinuoed headless browsers due to poor maintenance and support. 
Selenium automation utilized PhantomJs when it needs a non GUI mode executions on jenkins server when there is no browser installed on it or no support from docker containers.

What is OpenCV

What is opencv library ?

Open Source Computer Vision Library (OpenCV) is a open source computer vision and machine learning software library. 

OpenCV is a BSD-licensed product, since it is BSD licenses it can be utilized or modified for anyOpenCV businesses use. Sikuli has leveraged OpenCV for image recognition.

OpenCV was built to provide a common infrastructure for computer vision applications 

OpenCV helps to accelerate the use of machine perception in the commercial products. 

How does Karate framework work

What is Karate Framework and API test automation is done using Karate ?

Overview

Karate framework is the only framework that combines API, Web Automation, mock and performance testing using Gatling. It supports some level of RPA/RDA testing by integrating Sikuli with it’s scritps.

Stackoverflow links related with Karate framework

https://stackoverflow.com/questions/59768331/like-selenium-grid-hub-node-is-there-any-option-to-run-karatedriver-on-grid

https://stackoverflow.com/questions/58854004/karate-driver-synchronization-challeges

https://stackoverflow.com/questions/58783547/karate-driver-connection-refused-error-while-using-driver-type-chrome-and-exec

https://stackoverflow.com/questions/58634921/calling-karate-feature-files-based-on-soap-response-status-code-200-or-500

Karate framework can be build using gradle or maven. If you already know Cucumber framework it is easy to learn Karate framework. Karate uses feature files and Karate specific DSL supports both API and Web automation. Karate’s Java runner file can call the feature file having Karate DSL to perform API transactions like GET, POST, PUT and DELETE.

Karate version 0.9.5 released in 2020 has the following features,

  1. Debug from Visual Source code IDE
  2. Hot reload, step over / into / out / back

In 2019, Karate started web automation. Karate 0.9.5 feature will make Karate as complete test automation framework supporting both API and Web automation. Also another point to be noted is Karate’s integration with Sikulix for Desktop automation, integration with Gatling for performance testing and Mocking support for API testing.