Allure Reporting | Selenium WebDriver Framework| Page Object Model | TestNG | Maven- MAC,WINDOWS



As a tester we are mainly interested in generating very good html reports to get to know the Test cases passed and failed. TestNG which is a java framework helps us in generation of index.html and emailable-report.html contains the information about the Test case Status. Even though it generates the status of the testcases we are mainly interested in taking screenshots,generation of PIE charts,LINE charts. In this tutorial we are doing to discuss on usage of Allure Framework to generate reports for different languages : JAVA,PYTHON,JAVASCRIPT,RUBY,GROOVY,PHP,DOT NET and SCALA.

GENERATE ALLURE REPORTING:
Create a Maven project

Subscribe to our YOUTUBE channel for more updates on automation videos


Project Source Tree Directory Structure:
The standard layout for Maven projects (the application sources reside in ${basedir}/src/main/java and test sources reside in ${basedir}/src/test/java, where ${basedir} represents the directory containing pom.xml).

MavenDirectoryStructure-Allure configuration

MavenDirectoryStructure-Allure configuration

Configuration for Allure: pom.xml




Add the allure.properties under src/test/resources

TestExecutionListener.java

OpenMRSTests.java

OpenMRSPage.java

TestBase.java

ProjectConfiguration.java

totalqa.xml

Right Click on the project and select Run configuration

AllureConfiguration

AllureConfiguration


Maven Goals as ‘site’

maven goals site

View the Reports in Firefox Brower only.

allure-maven.html

allure-maven.html

Finally, we are able to capture the allure reports as shown below:

allure-maven.html

allure selenium report

History of Test Execution Results

AllureReportHistory

AllureReportHistory

Duration and Retries Trend

AllureGraphs

AllureGraphs

Refer to the below Links for Practice
Collections in Java
Complete List of Selenium Basics
50 Real Time Interview Questions
Real Time Scenario’s
Java Platform Standard Edition 8 Documentation
Java Quiz
Java OOPS Quiz
Selenium Advanced Quiz
Selenium Quiz

VALIDATE MULTIPLE LINES OF TEXT IN SELENIUM WEBDRIVER



FILE HANDLING SCENARIO’S IN SELENIUM WEBDRIVER:
1. Read the text displayed in the WEBSITE: Actual
Automate Coronavirus COVID19 REST API POST METHOD Tutorial Part2
2. Maintain this text in a txt file : Expected
Automate Coronavirus COVID19 REST API POST METHOD Tutorial Part2
3. Compare the values from STEP 1 and STEP 2.
4. Mark the TESTCASE as PASS/ FAIL.

JAVA API FOR READING THE CONTENTS OF THE TEXT FILE:
Following are the java classes useful in reading the text from the file.

  • import java.io.BufferedReader;
  • import java.io.File;
  • import java.io.FileReader;
  • import java.io.IOException;


Java Logic

Conclusion:
File Contents:: Automate Coronavirus COVID19 REST API POST METHOD Tutorial Part2
PASSED: validateTextfromWebPage

Automate Coronavirus COVID19 REST API POST METHOD Tutorial Part2




REST API Automation Testing Tutorial Part 2:In this tutorial we are going to focus on testing the HTTP POST method using REST ASSURED API. To know more details about the REST and REST ASSURED API and testing HTTP GET method. Please refer to this link.
1. Understanding Post Request
REST Endpoint URL : https://api.covid19api.com/auth/access_token
AUTHORIZATION: Basic Auth
Username:go-corona-admin
Password:5577YvzU4bK63a1WIQ3Z043H
Body:
{“Email”:”test1@covid19api.com”, “Subscription”:”basic”}
Response:
{ ‘result’ : ‘success’ }
Response Code:
200
Response Headers:
Server: nginx/1.14.0 (Ubuntu)
Date: Sun, 22 Mar 2020 08:07:30 GMT
Content-Type: application/json
Content-Length: 24
Connection: keep-alive
Vary: Origin

2. Design Test Cases

REST ASSURED REST API HTTP POST TESTCASES

REST ASSURED REST API HTTP POST TESTCASES

3. Pre-requisites
io.restassured
maven dependency
add the dependency in the pom.xml

4. Post Method Example

  • Validate Response Code
  • Validate Response Headers
  • Validate Response Body
  • Validate 401 unauthorized response


Java Logic

Conclusion:
Validated Response Code
Validated Response Headers
Validated Response Body
Validated 401 unauthorized response

REST ASSURED HTTP POST METHOD RESULTS

REST ASSURED HTTP POST METHOD RESULTS

Automate Coronavirus COVID19 REST API GET METHOD Tutorial Part1




1. Understanding REST & REST Assured API

REST stands for Representational State Transfer mainly uses the http protocol to exchange messages
between client and server using different methods such as GET,POST,PUT,DELETE.

Example :
COVID19 API Website Details
COVID19 API Details

Request Details::

  • REST API EndPoint: https://api.covid19api.com/
  • Method Type: GET
  • Request Headers:
    authority: api.covid19api.com
  • Query Params:

    https://getAllEmployees&empID=1

Response Details::

  • Response Code:200
  • Response Headers:content-type: application/json; charset=UTF-8
  • Response Body:{“allRoute”:{“Name”:”Get All Data”}}

2. Design Test-cases

Rest API Testcases

3. Pre-requisites for Automation REST Services:

com.jayway is a older version
io.restassured is the latest version
Eclipse
Maven project
pom.xml
io.restassured dependency
groupId: io.rest-assured
artifactId: rest-assured
version: 4.3.0

TESTNG – validate the test results

4. Get Method example
RestAssured

  • Response Code Validation
  • Response Headers Validation
  • Response Body Validation

Java Logic

Conclusion:
Validated Response Code
Validated Response Headers
Validated Response Body

REST API Results

COVID19 REST API Results

HTML Examples

      No Comments on HTML Examples


Sign In to view your account details.

SELENIUM
QTP
LOAD RUNNER
JMETER

Listbox Example



JAVA BASICS

SELENIUM BASICS AND ADVANCED TOPICS
SAMPLE QUIZZES

File upload in Selenium,Java,Robot Class

      No Comments on File upload in Selenium,Java,Robot Class


File Upload is achieved using the Java API java.awt.Robot class where awt stands for Abstract window Toolkit.
1. Robot class in java mainly useful to generate native system input events for the purposes of test automations.
2. The primary usage of Robot class is to facilitate automated testing of Java platform implementations
Test Steps:
1. Open Chrome Browser.
2. Enter the URL https://www.zamzar.com/.
3. Click on the button -Add Files
4. Opens the window Dialog box
5. Enter the absolute path of the file : C:\SeleniumArtifacts\TestCaseData.xlsx
6. Click on Enter button in the keyboard.


Java Logic

Expected Result:
File is uploaded successfully

Keyboard Actions:
1. ctrl + v ->C:\SeleniumArtifacts\TestCaseData.xlsx
2. enter
Conclusion:
File Upload is achieved in Selenium Automation Tool using the Java API.

Loggers in Java,Selenium for Beginners

      No Comments on Loggers in Java,Selenium for Beginners


A Logger object is used to log messages for a specific system or application component.
A Logger is useful to track the sequence of actions.
Each Logger has a “Level” associated with it. This reflects a minimum Level that this logger cares about.
The log level can be configured on the Logger.setLevel method.
Refer to the API Link for different levels.
Log Levels

  • SEVERE (highest value)
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST (lowest value)
  • OFF
  • ALL


Logic

Conclusion:
Logging using a java.util.logging.Logger class is easy to implement in Java and Selenium automation projects.
OUTPUT:

java.util.logging.Logger

java.util.logging.Logger

Write XLSX using Apache POI-Maven Project

      No Comments on Write XLSX using Apache POI-Maven Project



Apache POI (Poor Obfuscation Implementation File System) is the Java API for Microsoft Documents such as XLS,XLSX,DOC and PPT as well.
HSSF (Horrible Spreadsheet Format)
Read or write an Excel file format – XLS
XSSF (XML Spreadhsheet Format)
Read or write an Excel file format – XLSX
To download the Apache POI Library access the below link -> https://poi.apache.org/download.html
Download the Binary Distribution

  • Linux : poi-bin-xx.tar.gz
  • Windows : poi-bin-xx.zip

Apache POI
Writing the XLSX in JAVA project
1. Create JAVA Project
2. Add the dependencies of the Apache POI to the Build Path of the project.

Apache POI Referenced Libraries

Java Project – Build Path


3. Create a XLSX file with rows and columns
Apache POI-Xlsx File

Xlsx File


4. Write the logic to write the data to the XLSX.


Writing the XLSX in maven project
1. Create MAVEN Project
2. Add the following dependencies in the MAVEN pom.xml
https://mvnrepository.com/artifact/org.apache.poi/poi
https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
Maven Dependency- Apache POI

Maven Dependency- Apache POI


3. Write the logic to write the data to the XLSX.

Conclusion:
Reading the XLSX is easy using the Apache POI and Java API.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Output
WriteExcel using Apache POI

WriteExcel using Apache POI

Read XLSX using Apache POI – Maven Project




Apache POI (Poor Obfuscation Implementation File System) is the Java API for Microsoft Documents such as XLS,XLSX,DOC and PPT as well.
HSSF (Horrible Spreadsheet Format)
Read or write an Excel file format – XLS
XSSF (XML Spreadhsheet Format)
Read or write an Excel file format – XLSX
To download the Apache POI Library access the below link -> https://poi.apache.org/download.html
Download the Binary Distribution

  • Linux : poi-bin-xx.tar.gz
  • Windows : poi-bin-xx.zip

Apache POI
Reading the XLSX in JAVA project
1. Create JAVA Project
2. Add the dependencies of the Apache POI to the Build Path of the project.

Apache POI Referenced Libraries

Java Project – Build Path


3. Create a XLSX file with rows and columns
Apache POI-Xlsx File

Xlsx File


4. Write the logic to read the data from XLSX.


Reading the XLSX in maven project
1. Create MAVEN Project
2. Add the following dependencies in the MAVEN pom.xml
https://mvnrepository.com/artifact/org.apache.poi/poi
https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
Maven Dependency- Apache POI

Maven Dependency- Apache POI


3. Write the logic to read the data from XLSX.

Conclusion:
Reading the XLSX is easy using the Apache POI and Java API.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Output
Output of the Program

Output of the Program

Finding the Broken HyperLinks

      No Comments on Finding the Broken HyperLinks


HyperLinks in HTML useful to navigate to another web-page.
HyperLinks are defined using the tag name-a using an attribute name href.
We need to define the Link text between the tag name to get the text displayed on the web-page.
Clicking on the link redirected to a new window or in the same window. This can be defined using an attribute target.

  • target=_self -> opens the web-page in the same window
  • target=_blank -> opens the web-page in a new window

Using Locators in Selenium WebDriver, we can automate the steps to click on the link to navigate to a page defined under the attribute href as defined below:
Link_Text

href =”https://total-qa.com” target=”_blank”
Scenario:

Is there any way to identify the broken links using Selenium WebDriver?

HTTP ERROR CODE : 404

HTTP ERROR CODE : 404


The below logic helps in identifying the broken links.
Currently we are using WebDriverManager to instantiate the Driver Instance.

Conclusion:
Broken links in a web-page are identified using Selenium and Java API.