Where we learn technology

Category: Uncategorised (Page 1 of 7)

Selenium & Java Training Course Content – Regular Batch (21st February 2024 – 6:30 AM IST / 8:00 PM EST (Registration open now)

Selenium & Java Training – Regular Batch (21st February 2024)

PLEASE FILL THIS REGISTRATION FORM:

Hi Folks,

This time I’m introducing some amazing content on Java, Selenium and some different approaches on Framework Designing with some really complex real time use cases.

This will be a very different content from my YouTube channel. 

After a very high demand on Java+Selenium, here I’m going to start next batch from 21st Feb 2024 [6:30 AM IST / 8:00 PM EST /  5 PM PST /  7 PM CST]

 
Thanks for registering “Selenium & Java with end to end Framework & Test Dev Ops” By Naveen AutomationLabs.
 
 

Next Batch Starting from: 21st Feb, 2024
Duration: 15 weeks (4 days in a week) (Mon to Thursday)

As per the further registration process, you need to pay the registration fee:
For Candidates in India: 3000 INR
For Candidates in USA/UK/Europe/Aus: 50 USD



Total Fee: 

  • 17,000 INR (for Candidates in India) – including Registration Fee

  • 320 USD (for Candidates in USA/UK/AUS/Europe) – including Registration Fee

Location: Online (Zoom Meeting) – 1 hr + 15 mins 

ClassesTimings: (Monday to Thursday)
    • 6:30 AM IST (Indian Time)
    • 8:00 PM EST (US Time)
    • 5:00 PM PST (US Time)
    • 7:00 PM CST (US Time)

Note:

  • There will be 2 demo sessions (first two classes are demo sessions).

  • Demo Meeting link will be shared one day before the session.

  • After 2 demo sessions, pending amount must be paid.

  • 14,000 INR – for candidates in India
  • 270 USD – for candidates in USA/UK/AUS/CANADA
  • In case of any query on training:
    Please mail me at: naveenanimation20@gmail.com
    What’s app me at: +91-9902233400

Please fill this training registration form after making the payment.

 Payment Options:

Here I’m sharing the payment details. Please send me the screenshot of receipt via email after you makeing the payment without fail. 
mail me at : naveenanimation20@gmail.com 

CANDIDATES IN INDIA:

1. Pay by Credit/Debit Card:
If you want to use credit card/debit card, please use this secured stripe payment link:
 
REGISTRATION FEE (3000 INR):
REMAINING FEE(14000 INR):
Or you can pay total fee (17000 INR):
 
2. BANK TRANSFER:
Bank Details:
Payee name: NAVEEN KHUNTETA
Name of the Bank: ICICI bank
Address of the Bank: Bhandarkar Road, Pune
Bank Account Number: 624001553272
IFSC Code(11 Digit Code): ICIC0006240
 
3. Pay by GPay/PhonePe/Paytm/UPI:
ph: +91-9828866542
(You can scan the following scanner)
 
======================================

CANDIDATES IN USA/CANADA/UK/EUROPE/AUS/OTHERS:

 
1. Payment link using secured stripe:
Pay by Credit/Debit Card:
If you want to use credit card/debit card, please use this secured stripe payment link:
2. Bank Transfer:
Please find below bank details. You can make the transaction directly to the given account or make it via Western Union (only via bank transfer) / Xoom/Remitly or any other remittance.
 
Bank Details:
Name: Naveen Khunteta
Bank Account Number:  1015794367401
IBAN Number:  AE520260001015794367401
City/Country: Dubai, UAE
Swift Code: EBILAEAD
Address: Staybridge, DIFC, Dubai (UAE) – 500001
 

3.  Paypal:

Check out with PayPal

Note: If you are paying through PayPal, You need to pay 330 USD (10 USD will be the PayPal Fee).

 

Imp Note:

  • There will be 2 demo sessions. In case If you don’t want to proceed with the training. Full Registration amount will be refunded back to you after 2 demo sessions.
  • Candidate has to inform immediately after two demo sessions via email (in case of refund, else refund won’t be possible).
  • After 2 demo sessions, pending amount must be paid.
  • Zoom Meeting link and password will be shared to join the session before the session everyday.

Course Content:

Selenium WebDriver is a leading web automation testing tool in industry. It is one of the most popular tool. Selenium WebDriver jobs are on a rise and are highly paid and highly valued. Industry is shifting towards automation rapidly.
 
Today, every start up, product based and service based companies need Automation QA Engineer to automate their web apps.
 
With more and more applications becoming accessible through browser it becomes very important to learn Selenium WebDriver.
This course is designed to teach in depth concepts of Selenium WebDriver4.x and Java. We focus on the basics first and then move towards the advance concepts of Selenium, Java and framework development.
Note: This training will be covered with latest Selenium 4.x version.
 
Part -1: Basics of Java & Selenium
 
1) Automation : A brief introduction to automation and the need for automation. How automation will enable you to beat competition and make you get the better jobs in market.
• What is Automation Testing
• Use of automation Testing
• Tools for Automation Testing
• Why automation is important for you career?
• What is Selenium
• Advantage of Selenium
• Introduction to WebDriver

2) Core Java/Programming : This class will set you up for understanding Basic OOPs and java concepts. These concepts will be extremely important for you to become a good Automation tester. This section is specially designed so that can be followed by any Manual test very easily.

  • Data Types and Variables
  • String Class
  • Arithmetic Operators & Concatenation operators
  • Conditional & Decision Making
  • Single Dimensional Array
  • Loops (For, While)
  • Classes and Objects
  • Class Constructors
  • Functions in Java
  • Function Input Parameters
  • Function Return Types
  • Exception Handling
  • Inheritance
  • Polymorphism
  • Encapsulation
  • Data Hiding
  • Method Overloading
  • Method Overriding
  • Abstract class
  • Interface
  • Super/This Keywords
  • Final/Finally/Finalize Keywords
  • Concept of Garbage Collector and System.gc
  • Wrapper Classes
  • String Manipulation
  • Collections Basics (Array List, HashMap, Set, Hashtable)

3) Eclipse IDE : This topic might seem little off place here but it’s very important topic to understand the tool you are using. Eclipse will the primary choice of development environment and we will discuss features of eclipse here.

• How to use Eclipse
• How to run, stop, pause
• How to debug in Eclipse
• Understanding console output
• How to put a break point
• How to add Watch variables
• How to find errors from Problem window
• Usage of step into and Step over debug functionality
  • Interview Questions
4) Set up Eclipse : We will start with setting up WebDriver, so that every participant start flaunting off their newly learnt skills by writing some cool test programs:
• Download and install java
• Download and start Eclipse
• Download and configure WebDriver java client
• Set up a project
• Create packages
• Create a First Java test case
• Import WebDriver Source file
  • Interview Questions
Note: This training will be covered with latest Selenium 4.x version.
5) WebDriver Interface : This topic will make you familiar with the concept of browsers in WebDriver and how to launch basic Firefox browser using WebDriver. Here we will also talk about WebDriver & WebElement interface which will enable us to answer many complicated Interview Questions about WebDriver Implementation.
• Architecture of WebDriver
• WebDriver Interface
• WebElement Interface
• Launching Firefox/Chrome/Safari
  • Interview Questions
6) Browser & Navigation Commands : This is something which everybody do very first thing when they learn Selenium. Opening & closing of browser and some navigation function on top of it.
• How to Open a URL
• Verify Page title
• Strategy to get the Page Source 
• Difference between Close & Quit
• Ways to Navigate Back & Forward
• How to Refresh Page
• Another way of Navigating to specific Page
  • Interview Questions
7) WebElement Commands : An important and basic need of Selenium Automation. This part enables every participant to start writing automation test in their organizations. These are the most commonly used operations on any website.
• Difference between FindElement & FindElements
• Enter & Clear text from Input field
• How Click action works differently on different elements
• Managing Input fields, Buttons & Links
• Finding all links on the Page
• Extracting More than one object from a page 
• Extracting Objects from a specific area of a web page 
• Check if element is Present, Displayed, Enabled or Selected
  • Interview Questions
8) Locators : In this class we will start learning about HTML, how elements are defined inside HTML document and what are the different attributes that are associated with an HTML element. We also try to find elements based on its attribute values.
• What are locators
• HTML Basics
• HTML language tags and attributes 
• ID, Name, Xpath, CSS etc
• Difference between Absolute & Complete Xpath
• Finding your first element
• WebElement Commands
  • Interview Questions
9) Element Identification : This part explains the lifesaver Add-Ons & tools for Selenium. Finding elements are the most common activity carried out in Selenium. These tools give us power to easily identify complex elements and help us in saving lot of time.
 Element Inspector in Mozilla, Chrome and IE
• Element locator tool for FF
• Various HTML locator strategies
• XPath Helper Plug-in for Chrome
• Selection of Effective XPath
• Handling Dynamic objects/ids on the page
  • Interview Questions
10) Tables, Checkboxes & Radio buttons : Many applications involve use of web tables and list boxes. These skills will help participant to get the expertise on complex tables structures and write effective automation test.
• Identify table rows and columns
• Extracting values from a cell
• Dynamically Identify Tables Data
• Select class in Selenium
• Drop Down Handle
• Select multiple values from the list
• Select & Deselect operations by Index, Value & Visible Text
  • Interview Questions
11) Selenium Waits, Alert & Switch Windows : A little complexity will start now onwards. To use Waits effective is very important for every automation tester. Wait helps us in switching windows, handling pop-ups, operating alerts correctly.
• Implicit and Explicit waits
• How to use Expected Conditions with Waits
• PageLoadTimeout & SetScriptTimeout property
• Simple use of Thread Sleep
• Concept of Fluent Wait in Selenium 
• Strategy to poll for an object
• WebDriverWait and its uses 
• Different WaitUntil Conditions 
• Managing Ajax based components 
• Ways to handle Simple, Confirmation & Prompt Alert
• Concepts of Set Interface in Java 
• Difference between Window Handle & Handles 
• Switching & Closing Windows, Tabs & PopUps
• Concept of window ID 
• Extracting window IDs with Selenium Object reference
  • Interview Questions
12) Actions Class
This gives us power on recently build Application with latest and complex object features. Hovering mouse or simulate Mouse and Keyword operations can be done by using Action Class. A necessary thing to learn in Selenium journey.
• What is Action Class & What can we do with Action Class
• Mouse Hover & Mouse Movement with Action
• Drag and Drop Action
  • Right Click (Context click
  • Click and SendKeys using Actions Class
  • Interview Questions
13) Browser Profile: Different types of browser profiles and user authentication models with examples will be discussed in this class. You will need these to test secured websites and user authenticated websites.
• What is Browser Profile
• How to set up ChromeOptions and Firefox Options
 
14)Complex UI Scenarios:
  • Handle Ajax components
  • Handle Complex Calendars
  • Handle WebTable with Paginations
  • Handle infinite Page Loading like infinite page scrolling on linkedin, facebook, food delivery web apps
  • Complex ShadowDOM, SVG Elements
  • Complex Frames/iFrames
  • Complex Psuedo Elements
  • Page Wait use cases
  • Element Wait use cases
 
Part -2: Advanced Selenium
 
14) TestNG Framework
TestNG is a wonderful off the shelf framework that can be used directly to create your test framework. We will learn about this framework here.
• What is TestNG
• Benefits and Features of TestNG
• How to download TestNG
• Annotations in TestNg
• How to run Test Suite in TestNG
• Groups in TestNG
• Depend On in TestNG
• Test Case sequencing in TestNG
• TestNG Reporters
• TestNG Assets
• TestNG Parameters
• Multi Browser testing in TestNG
• Parallel testing in TestNG
  • Interview Questions
15) Automation Framework (End to end Project)
This class will cover the concepts of Frameworks. After this the participant would got to know that which type of Framework works best for their Application and the pros & cons of the selected framework. Knowledge of frameworks is key skill to learn.
• What is Automation Framework
• Features of Automation Framework
• Benefits of using Automation Framework
• What is Data Driven Framework
• What is Hybrid Framework
  • What is Page Object Model Design Pattern with Non Page Factory (By Locators) with OOP concepts
  • Interview Questions
16) Real Time Live PROJECT On EComm Application– Selenium Hybrid Framework (POM)
In this class we will explore some major frameworks by looking at the code and understanding the key component of the framework. 

A real time web application will be taken and framework will be built on top of that which will simulate actual project scenarios. We follow the best practices for framework development, this is what we do in real time projects.
• Introduction and Component of Frameworks
• Designing Test Data Provider (Excel)
• Designing Run Data Provider (Text/Property file) 
• Setting up Maven Build Tool
• Data Provider Design
• Creating Page Objects & Object repository
• Writing Test Script and Fetching Test Data
• Designing Test Runner for Framework
• Asserts, Test Fails & Error logging
• Reporters, TestNG Listeners and Log file Generation
• Running test with different Test Data
• Generating the HTML reports : Extent Report, Allure Report, TestNG Report

17) Dev Ops & Continuous Integration 

  • Jenkins Setup Basics
  • Running Script via Jenkins
  • Jenkins PipeLine – Classic View
  • Jenkins PileLine – Blue Ocean
  • Jenkins PipeLine Syntax
  • Jenkins Report Generation using Extent Report, Allure and TestNG Report
  • Git WebHook with NGRok Proxy to trigger the build automatically
  • GIT Repo/GIT HUB
  • Learn how to use commit command
  • What is cloning in GIT
  • what is GIT Fork
  • My First Code Check-in to GIT
  • GIT PULL Request Process (PR, Merge Request)
  • GIT CheckOut
  • GIT Branching (Local branching Concept)
  • What to do when you join a new team – how to use GIT commands properly
  • GIT best practices
  • GIT Merge
  • GIT Commit
  • GIT ADD
  • GIT Push, Fetch & Pull Commands
  • GIT Merge Conflicts
  • GIT Stash
  • Git Stash Pop
18). Maven Life Cycle
  • Maven Commands
  • Maven Life Cycle stages
  • Create -> Compile -> Run Tests -> Package -> Install -> Deploy
  • Creating build JAR
  • Generation of FAT JAR using Assembly plug-in
  • Maven Nexus Deployment using maven deploy plugin

19). Docker

  • What is Docker
  • What is Docker Container
  • How to create account on Docker Hub
  • Selenium Grid Configuration on Docker Hub
  • Run your test cases on Dockerized Selenium Grid Hub – Node setup
  • Setup Infrastructure using Docker Compose yml 
  • Scale up the browsers at the run time
  • Shut down the Docker Infrastructure
  • Selenoid Grid Setup
  • Selenoid with docker-compose and browsers.json
  • Cross Browser with specific version using Aerokube Selenoid Dockerized Grid
  • Setup your own Browsers Lab with different browser versions
20). AWS – Amazon Web Services – 
  • Introduction
  • Setup Account
  • Create new EC2 Instance on AWS
  • Create AMI, Security Group, VPC and Subnets
  • Selenium Dockerized GRID Setup on AWS – EC2 machine
  • Run Selenium test cases on AWS machine
  • Setup complete dockerized grid on AWS cloud using Selenoid GRID and Docker
21). Life Time Access on all recorded Videos, Free Code Repos, and Java Code, important notes, pdfs and e -books.

Some of the reviews from my previous batch candidates, most of the students either got promoted  to test automation or got their dream automation jobs.
 
 
 
 
 

 
 
 

Frequently Asked Questions:

Q1: Will I get the recordings for these sessions?
Ans: Yes, you will get the recording daily basis for the specific topic after the session.

Q2: Is this training useful for freshers?

Ans: 100% useful for freshers, who are looking for to start their career into automation QA field.

Q3: Is this training useful for Manual Testers?

Ans: 100% useful for Manual QA folks, it will surely help to trigger your interest from manual to Automation QA. After this training, you will become an expert in automation. 

Q4: Can I justify my automation knowledge, after this training?

Ans: Yes, training will help you to learn right automation with proper guidance. You have to practice accordingly to justify your automation knowledge.

Q5: Can I crack selenium interviews after this training?

Ans: Yes, 100% guarantee. 

Q6: What is the duration of this course?

Ans: I never compromise in training content and syllabus. It depends how exactly we are going with this training. Ideally it should take around 15 weeks. It might take more than 15 weeks also.

Q7: Who will be the trainer?

Ans: Only Naveen from Naveen AutomationLabs. We don’t allow other trainers to take sessions.

Q8: Will this training be different from existing YouTube videos?

Ans: Yes, it will be more in-depth training and more topics will be covered with different scenarios along with one end to end framework as per industry standards (no copy paste) with full Infrastructure and dev ops setup.

Q9: What if I miss any session?

Ans: You will get each session recording daily basis. You can cover that topic after watching the recordings.  You will have the recordings with the lifetime access.

Q10: Will assignments be shared for covered topics?

Ans: for almost every important topic, I have assignments and will be shared daily basis. 

Q11: Can I improve my programming skills after this training?

Ans: I am 100% sure, it will drastically improve your coding skills and logical thinking for writing the best optimized code.

Q12: How will you cover the topics? Is it only theory or any real time experience?

Ans: I always try to relate the topics with real time scenarios, how exactly test automation works in real time projects and I hardly copy paste the code. I strongly prefer to write the code during the session. No COPY PASTE. NO Power Point Slides, No Boring Theories.
 
Q13: Do you provide any certification?
Ans: We can provide Course completion certification but this is just a certification. We never claim that this certification is globally recognized. You need to submit the coding assignments and GIT Repository URLs to get the course completing certification.

In case of any questions: Feel free to ping me on whats app : +91-9902233400.

Thanks for enrolling for Java and Selenium Training – By Naveen Automation Labs.

This batch is different from other previous batches, as I have some more new content in Java and Selenium with new style of framework designing part and much more.
I’m sure you will learn a lot of new things from this training. “A lot to know – A lot to learn”.
This course is huge and we really need to maintain the pace of the course, so that you all can learn the things within the given time frame. We never compromise in terms of content and quality of the training.
Few important points to remember before joining the training session:
  1. It will be online training and sessions will be recorded daily basis. Please try to join before 5-10 mins of the session time.
  2. I want you to be on mute during the session so that session should not get disturbed due to any background noise. Otherwise, it will break my rhythm as well as it will disturb the entire class.
  3. If you have any questions, you can ask in goto meeting chat section. If you have any background noise, please don’t unmute yourself. Please attend these sessions at a quite place with good internet connectivity and with good headphones.
  4. Best option is to write your question/query in chat section. I always believe, if it’s a pin drop silence, classroom decorum will be maintained properly. 
  5. After the session, recording will be shared by EOD – daily basis.
  6. You can access these recordings with Life Time Access. Downloading of the videos are strictly not allowed.
  7. It’s strictly not allowed to share these videos with anyone, if it is found, the respective candidate account will be terminated immediately.
  8. It’s not allowed to create any whats app/telegram group for this training batch. If you have any suggestions or feedback, feel free to reach me out. I would love to hear from you.
  9. Session will be there for 60 mins (+30 mins extra for doubts).
  10. We will have two demo sessions, if you don’t want to continue with the training, registration money will be refunded back.
  11. After demo sessions, pending amount has to be paid as per the fee structure.
“Happy Learning” 🙂

Cheers!!

Naveen AutomationLa

GIT Paid Course – Basics to Advanced

GIT –

By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.

Developers who have worked with Git are well represented in the pool of available software development talent and it works well on a wide range of operating systems and IDEs (Integrated Development Environments).

Having a distributed architecture, Git is an example of a DVCS (hence Distributed Version Control System). Rather than have only one single place for the full version history of the software as is common in once-popular version control systems like CVS or Subversion (also known as SVN), in Git, every developer’s working copy of the code is also a repository that can contain the full history of all changes.

In addition to being distributed, Git has been designed with performance, security and flexibility in mind.

These are the paid videos (not the live training). You will get all the videos from Box repository with life time access. You just need to send me the mail once you make the payment. Please send the details at : naveenanimation20@gmail.com Mail Subject Line: GIT Course Payment Receipt – Your Full Name Click here to BUY:

Discounted Price: 1299 INR (20 USD)

Actual Price: 2250 INR (35 USD)

Course Content:

1. What is GIT (Introduction)

2. GIT Installation on Windows/MAC
  • GIT global configuration
3.  GIT Architecture
  • What is working copy (workspace)
  • What is stage/index
  • What is local repo/branch

4. GIT first commit

  • Create new git hub account on git hub cloud
  • git init
  • git remote add origin
  • git add .
  • git add
  • git add <folder/dir>
  • git push origin master (push your first code to git repo at remote)
  • setup git username, email id and password
  • git authorization
  • Git Hub Overview
  • Git HUB – remote repo creation
  • Practical Implementation with live examples

5. GIT – 2nd commit

  • Add a new file
  • Update a file
  • Delete a file
  • add -> commit -> push it again to remote branch
  • Practical Implementation with live examples

6. GIT logs/history

  • git logs
  • git logs with various options
  • git logs with filters
  • git logs with different options
  • git view commit
  • check commit
  • check commit history
  • Practical Implementation with live examples

7. GIT diff

8. GIT blame/ GIT short log

9. GIT local branching process

  • Complete workflow
  • Deep understanding of stage/index and local repo
  • How to cut a feature branch
  • git checkout
  • git checkout vs git switch
  • git checkout with git branch
  • git branch (create a new branch)
  • git add . (add working copy objects to stage/index)
  • git add <file/folder>
  • How to commit a code
  • git commit -m
  • git push origin
  • Practical Implementation with live examples

10. PR (Pull Request) Process

  • What is PR (Pull Request)
  • git merge at remote side
  • PR – review 
  • PR – feedback
  • PR – request changes (rejected)
  • PR – mail notification
  • PR – approval
  • Update PR
  • PR transaction between developers
  • PR comments
  • PR best practices
  • Practical use cases of PR
  • Practical Implementation with live examples

11. GIT various branching commands:

  • Create branch
  • Delete branch
  • Branch list
  • Local branch list
  • Remote branch list
  • Checkout/Switch branch
  • Practical Implementation with live examples

12. GIT Clone vs GIT Fork

  • What is git clone
  • How to clone
  • Why to clone
  • Import cloned repo to current working copy in editor (eclipse, IntelliJ)
  • Git forking process
  • How to fork any repo at remote side
  • Practical Implementation with live examples

13. GIT Local Merge

  • Git local merge use cases
  • git merge
  • git merge master to feature branch
  • git merge feature to master branch
  • git merge best practices
  • git merge and no merge branches
  • Practical Implementation with live examples

14. GIT Tag and Releases

  • What is tag
  • What is release
  • How to tag a git commit with a specific version
  • How to push the tag to remote
  • How to create various tags for different features in your project
  • How to create a release version from the specific tag
  • How to create a latest release from tag at remote side
  • Release notes
  • Practical Implementation with live examples

15.  GIT Fetch vs PULL

  • What is git pull
  • What is git fetch
  • Diff between fetch and pull
  • Why git pull = git fetch + merge
  • Practical example of git fetch and git pull
  • Practical Implementation with live examples

16. GIT Merge vs Rebase

  • What is actual merge
  • git merge and how it works
  • git merge with visual design diagrams
  • git rebase
  • git rebase with visual design diagrams
  • Main diff between merge and rebase
  • When to use git merge and rebase
  • Best practices
  • Practical Implementation with live examples

17. GIT Cherry-Pick

  • What is cherry-pick
  • How to perform cherry-pick merge from master to feature branch
  • How to perform cherry-pick merge from feature to master branch
  • Why cherry-pick is popular
  • Cherry-pick practical examples
  • Practical Implementation with live examples

18.  GIT Stash

  • What is stash
  • How to perform git stash
  • git stash
  • git stash pop
  • git stash list
  • Practical Implementation with live examples

19. GIT Merge Conflict

  • What is conflict
  • Why do we get conflict
  • Merge conflict with git stash
  • Merge conflict with git pull
  • Merge conflict with various use cases
  • How to understand git conflict
  • How to resolve git conflict
  • How to check git conflicts in editor
  • Stash changes in merge conflict
  • Latest pull changes in merge conflict
  • Practical Implementation with live examples

20. GIT Aliases

  • What is git alias
  • How to create custom global git alias
  • Various shortcut alias examples
  • git log alias
  • git checkout alias
  • git status alias
  • git switch branch alias
  • git commit log alias
  • Practical Implementation with live examples

21. Comparing two commits

  • Comparing two commits using git diff
  • Practical example of git diff to compare various commits in local 
  • Practical Implementation with live examples

22. GIT Reset

  • What is git reset
  • git reset options
  • git –soft reset
  • git –mixed reset
  • git –hard reset
  • git reset workflow
  • git reset design
  • How to delete a commit history
  • How to delete a file from stage
  • How to delete a commit history from local repo
  • How to delete a commit history from local repo and delete file from stage
  • Un-stage a file
  • How to delete a file from working copy using git hard reset
  • git force push to remote
  • Reset remote changes
  • Practical Implementation with live examples

23.  GIT Revert

  • What is git revert
  • How to perform git revert
  • Diff between git reset and git revert
  • Practical Implementation with live examples

Buy Now:

Grab it in just:

Discounted Price: 1299 INR (20 USD)

Actual Price: 2250 INR (30 USD)

Payment Options:

Here I’m sharing the bank account details.

Please send me the screenshot of the receipt once you make the payment without fail. 


Please send the details at : naveenanimation20@gmail.com

Subject Line: GIT Course Payment Receipt – Your Full Name

You can make the payment via payment link:

Pay via Debit/Credit Card – Click on link  

OR Via Bank Transfer:

Please find below bank details: 

You can make the transaction directly to the given account or make it via Western Union Or Xoom.

Bank Details:

Full Name: NAVEEN KHUNTETA
 
Contact No.: 9902233400
 
Payee name: NAVEEN KHUNTETA
 
Name of the Bank: ICICI bank
 
Address of the Bank: Bhandarkar Road, Pune
 
 Bank Account Number: 624001553272
 
 IFSC Code(11 Digit Code): ICIC0006240
 

You can send via PayPal or Xoom also:

PayPal Payment:  https://paypal.me/naveenautomation

Xoom Payment:

https://www.xoom.com/india/send-money

You can also make the payment via Tez (Google Pay) OR PhonePe :

UPI to this number: +91-9902233400

UPI: naveenanimation20@okicici 

OR Google IDnaveenanimation20@gmail.com

PING ME AT +91-9902233400, IN CASE OF ANY ISSUES.

For Candidates in India:

Please scan this QR code to make the payment via PhonePe, GPay / PayTM/ Amazon Pay/ UPI.

Note:

  • Once you make the payment, please send me the payment screenshot to:

         naveenanimation20@gmail.com

  • All the paid videos will be shared via Box drive.

Terms & Conditions:

1. For the paid course, refund is not applicable.

2. In case of any need of resume, you can mail me or tag me in Box comments section.

3. You can mail me or tag me in Box in case of any technical questions and doubts.

4. Response time of the queries within 24 hrs. 

5. Technical queries won’t be resolved over whats app messages. 

6. Feel free to ping me, in case of any Box issues.

7. This is strictly not allowed to share your credentials with anyone, if any account is found, it will be deactivated and account will be terminated.

Cheers!

Happy learning!

Naveen AutomationLabs

Building a Test Automation Framework Using Cypress with Cucumber

 
 

 

 

                                          ~Source: Google

Introduction:

In this Article, We are going to learn about creating UI Test automation framework with Cucumber BDD Approach.

What is BDD ?

  • Behaviour-driven development is an Agile software development process that fosters collaboration between developers, software testers, and the non-technical, business side in a software development process.
  • It asserts how an application should behave from the end user’s perspective.

Why Cypress ?

  • Front end testing tool built for the modern web applications.
  • Because of its Architectural design, Cypress delivers fast, consistent and reliable test execution compared to other Automation tools
  • Cypress takes snapshots as your tests run. We can hover over each command in the Command Log to see exactly what happened at each step. 
  • Cypress automatically waits for commands and assertions before moving on. 
  • Ability to test edge test cases by Mocking the server response.

Cypress Project Setup with Cucumber:

  • Download Node js from https://nodejs.org/en/download/ as per your operating system, as the cypress is built on the node js.
  • Create a folder and import the folder in any editor atom, sublime or visual studio code and open the terminal.
  • Setup a new npm package : npm init, this will create package.json in your project.
  • Open the terminal and enter npm install cypress cypress-cucumber-preprocessor, this will install cypress and cucumber in your project.
  • Dependencies should get added in package.json file.
  • Execute a command npx cypress open and you will be displayed with these folders in editor’s Left Pane.

Editor Left Pane

To enable the cucumber preprocessor plugin:

Open cypress/plugins/index.js and this snippet

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

Add support for feature files to your Cypress configuration

cypress.json{
  "testFiles": "**/*.feature"
}

Add this section to your package.json:

"cypress-cucumber-preprocessor": {
  "nonGlobalStepDefinitions": true
}
To bind our step definitions to our features files.

Cucumber Feature File:

feature file can contain a scenario or can contain many scenarios in a single feature file but it usually contains a list of scenarios in English format using some BDD keywords and the language is called “Gherkin“.

Steps:

  • Create a folder under the Integration folder as CucumberTests
  • Create a file login.feature and click login.feature and type Feature and the syntax for the same will get poped up automatically:

Type Feature in feature file

Provide Feature name, Feature Description and Type Scenario and give Scenario name.

Feature File

Let’s try to understand the Feature File:

After the Scenario, we need to write certain statements with Keywords Given, When, Then, And also But. 

  • Given: It describes the pre-requisite for the test to be executed.
  • When: It defines the trigger point for any test scenario execution.
  • Then: It holds the expected result for the test to be executed.
  • And: It provides the logical AND condition between any two statements
  • But: It signifies logical OR condition between any two statements.

Now, We have to create the step definition for the test written in the feature file:

Since we have feature file with us, now we have to create step definition file for the same :

  • Create a folder login, remember folder name should be the same as the name of feature file. 
  • login.feature is the feature file name and folder should have name as login
  • Under the login folder, create a loginSteps.js file and start Mapping the test steps with feature file test cases.

and folder in left pane and step definition would look like below:

Step Definition in loginSteps.js

Hit the command npx cypress run and output on console will be displayed as below:

Output after Running feature file

and to run in Test runner enter the command npx cypress open in the terminal and then run feature file and will be displayed as below:

Step Definitions with Dynamic Parameters:

Say, when you have to pass username and password as dynamic values below is the code snippets to be followed

Feature: Login Tests

Login Test Cases

Scenario: Login with valid credentials

Given Login to the application
When I type username as "username"
And I type password as "password"
Then click Login
And See the homepage

import { Given , And , Then , When} from "cypress-cucumber-preprocessor/steps";

Given('Login to the application', () => {
   cy.visit('http://zero.webappsecurity.com/login.html')
  })
  
  When('I type username as {string}',username=> {
    cy.get('#user_login').type(username)
  })
  And('I type password as {string}',password=> {
    cy.get('#user_password').type(password)
  })
  Then('click Login', () => {
    cy.get('input[name="submit"]').click()
  })
  And('See the homepage', () => {
    cy.get('a:contains("Zero Bank")').should('be.visible')
  })
  

and In the Test Runner, it will be shown as with proper Given, When, Then and And statements:

Test Runner when passed Dynamic values

Concept of Grouping and Filtering of Test Cases/ Smart Tagging:

when you have multiple scenarios and wanted to check few test cases to run, just put @focus on the specific scenarios you want to run:

@focus on 1st sceanrio

and it skips the other test case in Test Runner.

Also, you can tag your test cases with @smoke and @Regression test cases and run the particular scenarios from your command line with the below command :

  ./node_modules/.bin/cypress-tags run -e TAGS=’not @Smoke and (@Regression or @Sanity)’

Hooks Support in cypress and cucumber:

  • The cypress-cucumber-preprocessor supports both Mocha’s before/beforeEach/after/afterEach hooks and Cucumber’s Before and After hooks.
  • Cucumber Before hooks run after all Mocha before and beforeEach hooks have completed and the Cucumber After hooks run before all the Mocha afterEach and after hooks.
  • As we are using Mocha test framework with cucumber and cypress, it’s always good to go with Mocha hooks.

Let’s begin to Explore Data Driven Testing with cucumber:

Feature File:

Feature: Login Tests

Login Test Cases

Scenario: Login with multiple credentials
Given Login to the application
When I type the credentials
| uname | pword |
| username | password |
| hello | world |
Then click Login

To pass multiple test data set, you define the test set in tabular form like done above:

import { Given , And , Then , When} from "cypress-cucumber-preprocessor/steps";

Given('Login to the application', () => {
   cy.visit('http://zero.webappsecurity.com/login.html')
  })
  
  When('I type the credentials',function(dataTable) {
    cy.get('#user_login').type(dataTable.rawTable[1][0])
    cy.get('#user_password').type(dataTable.rawTable[1][1])
    cy.get('#user_login').type(dataTable.rawTable[2][0])
    cy.get('#user_password').type(dataTable.rawTable[2][1])
  })

  Then('click Login', () => {
    cy.get('input[name="submit"]').click()
  })


 

Let’s try to understand the code:

To fetch the test data, just write dataTable in function and as I have defined 2D array, fetch first username as dataTable.rawTable[1][0] that means raw one and 0 coloumn and it will fetch username as “username”.

Generating HTML Cucumber Reports:

Add below code snippet in package.json

 "cypress-cucumber-preprocessor": {
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  }

and remember we have already have cypress-cucumber-preprocessor “nonGlobalStepDefinitions”: true, after that cucumberJson should be put in package.json and output will be generated under cypress/cucumber-json.

cucumber.json file:

login.cucumber.json

And to create HTML report : Install this plugin with the following command:

  • npm install multiple-cucumber-html-reporter –save-dev
  • Add cucumberHTMLReport.js file under your parent project and paste the below code:

const report = require('multiple-cucumber-html-reporter');

report.generate({
	jsonDir: './path-to-your-json-output/',
	reportPath: './path-where-the-report-needs-to-be/',
	metadata:{
        browser: {
            name: 'chrome',
            version: '60'
        },
        device: 'Local test machine',
        platform: {
            name: 'ubuntu',
            version: '16.04'
        }
    },
    customData: {
        title: 'Run info',
        data: [
            {label: 'Project', value: 'Custom project'},
            {label: 'Release', value: '1.2.3'},
            {label: 'Cycle', value: 'B11221.34321'},
            {label: 'Execution Start Time', value: 'Nov 19th 2017, 02:31 PM EST'},
            {label: 'Execution End Time', value: 'Nov 19th 2017, 02:56 PM EST'}
        ]
    }
});

Configure jsonDir and reportPath as or the way you want :

Now, we need to execute this js file to get the HTML Report , just hit the command as node cucumberHTMLReport.js

Output for HTML Report

Open this file in browser to get full-fledge HTML report:

HTML Report with Features, Scenarios and Run info with how total test cases, passed, failed state.

 

For the code reference, please clone the project from:

https://github.com/MandeepKaur2020/CypressFrameworkBDD.git

References:

Conclusion:

In this write up, we learnt about how to create test automation framework using cypress with cucumber and generated some good HTML Reports.

Blog Contributors:

Author:  Mandeep Kaur
Mandeep, having 5+ years of Testing experience in automation using Selenium (Java) and Cypress. Expertise in API using Rest Assured, HTTP Client and Performance testing using JMeter.

https://www.linkedin.com/in/mandeepkaur93/

Reviewer: Naveen Khunteta 
https://www.linkedin.com/in/naveenkhunteta

 

 

 

 

A Quick Introduction About Karate DSL

Bonjour TestCommunity!!! 

According to worldwide Google Trends of the IT sector, the demand for well-trained API (Backend) testing professionals has increased substantially.

With the growing need of API testing, the tools and technologies are progressing hand-in-hand which focuses on improving performance, ease-of-use, reliability and accessibility

Why Karate DSL is the best tool for API Automation ?

Karate DSL is becoming a fore-runner of the tools and technologies available, fulfilling all these parameters in a short period of time.

Courtesy: Karate logo

With 4.4K GitHub stars and 1.1K GitHub forks, Karate DSL is progressively becoming popular amongst the QA community.

It is an Open Source Web-Services Test Automation Solution that integrates in a unified framework API test-automation, performance-testing and even UI automation.

It is developed on top of Cucumber-JVM, which enables us to build API-based BDD (Behaviour Driven Development) test scenarios for testing which means Gherkin becomes the primary programming language.

However, unlike the BDD framework, Karate DSL has omitted step-definition file writing efforts for the corresponding feature file i.e. we can execute the feature file comprising of all the test cases without defining step-definition file with the help of TestRunner class.

In addition to these benefits, there are numerous points of interest recorded below:

  • Karate DSL uses english-like language – Gherkin.
  • Powerful JSON & XML assertions along with “deep-equals” payload assertions. 
  • You do not need to write additional “glue” code or Java “step definitions” Java. 
  • Parallel execution feature offered by Karate in turn reduces the test execution time. Hence, making it a very fast API testing tool
  • For large responses, data validation becomes easier by “match” keyword.
  • Data-driven tests that can also use sources from JSON or CSV
  • Even for non-programmers, tests are simple to write, i.e. it is based on the common Cucumber / Gherkin standard with syntax colouring options.

Looking at the wide range of Karate DSL features, aren’t you curious about learning and using this awesome tool?

In my forthcoming blog, let us explore Karate in depth along with its setup and configurations.

Did you find this blog informative ? Please share your views in the comment section below or you can follow me on LinkedIn.

Till then stay safe and Happy Learning !!! 



Blog Contributors: 

Author: Priyanka Brahmane

Priyanka is an Automation tech enthusiast having an industry expertise of more than 6 years with a special bent for Karate DSL and Web Automation.
 
She is a staunch believer in the “one is always a learner” theory.
She can be connected on LinkedIn and follow me on Medium.
 
Reviewer: Naveen Khunteta
https://www.linkedin.com/in/naveenkhunteta/

HTTP POST Method Using RestAssured

 

                      ~ Image Source:google/.sashido.io/

Introduction

In this article, we are going to learn about the HTTP Post Method in detail and various ways to create a post payload, in addition to that, we will also learn how to validate Post Response using RestAssured.

Writing post Method

Let’s start writing our first positive scenario :

  1. Given Accept the given content in JSON format
  2. with content type as JSON
  3. and Body
  4. when I performed the Post Request
  5. Then status Code should be 200 OK
  6. And The response should have name as given in JSON body

 

Code with Positive test case

  • As depicted in the screenshot, Primarily, to hit the JSON HTTP post request we need to have JSON Body and passing the JSON body as a string in Body function would suffice our need.
  • This means, once we have the body, we can simply pass our endpoint here in the .post function and once it is successful, we need to assert whether we get the expected output or not.
  • Below is the code for same:

Note: Content type can be XML if you are using XML, else it would be JSON

package com.restassured.tests;

import io.restassured.http.*;
import org.apache.http.HttpStatus;
import org.testng.annotations.Test;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

/**
 * @Author: Mandeep Kaur
 */
public class PostMethodTest {

    @Test
    public void sampleTest() {

        // Json Body to pass in the request
        String jsonBody = "{" +
                "   \"name\":\"Test Automation\",\n" +
                "   \"gender\":\"Male\",\n" +
                "   \"email\":\"testAutomation3@gmail.com\",\n" +
                "   \"status\":\"Active\"\n" +
                "}";

        given().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f")
                .accept(ContentType.JSON)
                .contentType(ContentType.JSON)
                .and()
                .body(jsonBody)
                .when()
                .post("https://gorest.co.in/public-api/users")   //hit the post end point
                .then().
                assertThat()
                .statusCode(HttpStatus.SC_OK)
                .and()
                .body("data.name", equalTo("Test Automation")); // Match the output actual to expected

    }
}

Another scenario is the negative case:

Would be if we send the same request, then it should return the response code as “422” and message as email has already been taken because to create user every time unique email should be passed:

Code with negative test case when an email is already existing

JSON Object

Now, the other way of creating the payload/ request is through JSON Object:

JSONObject is an unordered collection of key and value pairs, resembling Java’s native Map implementations.

  • Keys are unique Strings that cannot be null
  • Values can be anything from a Boolean, Number, String, JSONArray or even a JSONObject.NULL object
  • A JSONObject can be represented by a String enclosed within curly braces with keys and values separated by a colon, and pairs separated by a comma
  • It has several constructors with which to construct a JSONObject

Instead of sending the hardcode JSON body, we can send customize data along with post request.

For this scenario,  what we need to do is :

Add this maven dependency in your project

Json Dependency

After that manipulate below JSON request to JSON Object:

{
"name":"Test Automation",
"gender":"Male",
"email":"testAutomation6@gmail.com",
"status":"Active"
}

And here’s the below code for the same :

Post Request by JSONObject

package com.restassured.tests;

import org.json.JSONObject;
import org.junit.Test;
import io.restassured.http.ContentType;
import static io.restassured.RestAssured.given;

/**
 * 
 * @author Mandeep kaur
 *
 */

public class SamplePostRestTest {

	@Test
	public void createUser_whenSuccess() {


		JSONObject jsonObject = new JSONObject();

		//insert key value pair to jsonObject
		jsonObject.put("name", "Test Automation");
		jsonObject.put("gender", "Male");
		jsonObject.put("email", "testAutomation14@gmail.com");
		jsonObject.put("status", "Active");

		String resp=  given().log().all().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f23")
				.accept(ContentType.JSON)
				.contentType("application/json")
				.and()
				.body(jsonObject.toString())
				.post("https://gorest.co.in/public-api/users")   //hit the post end point
				.thenReturn().asString();

		System.out.println(resp);

	}
}

As can be seen, We can use JSONObject and insert the values in the attribute just like hashMap in java and later on, can pass the JSON object in String. After that, validations can be performed accordingly:

And From hashMap also we can create JSON Object like below:

Map<String, String> map = new HashMap<>();
map.put("name", "Test Automation");
map.put("gender", "Male");
map.put("email", "testAutomation14@gmail.com");
map.put("status", "Active");
JSONObject jo = new JSONObject(map);

and this jo object reference can simply be passed in the request.

Since this nature of post request is quite simple, so for the complex request, you need to modify the request as per given specification.

Let’s take a small example:

[
    "Employee",
    {
        "city": "chicago",
        "name": "john",
        "age": "36"
    }
]

Now here it is having array and then a JSON object :

To build this request we need to have this below structure:

JSONArray jsonArray = new JSONArray();
jsonArray.put("Employee");

JSONObject jo = new JSONObject();
jo.put("name", "john");
jo.put("age", "22");
jo.put("city", "chicago");

jsonArray.put(jo);

To illustrate the example above, we first need to create the JSON object and insert values in it, once done then we need to pass this object in JSON Array which again comes from org.json package(below-detailed description of JSONArray), JSON array has its own element as “Employee” which can also be inserted using put() method and finally we can insert this JSONArray into request body like below

JSONArray is an ordered collection of values, resembling Java’s native Vector implementation.

  • Values can be anything from a Number, String, Boolean, JSONArray, JSONObject or even a JSONObject.NULL object
  • It’s represented by a String wrapped within Square Brackets and consists of a collection of values separated by commas
  • Like JSONObject, it has a constructor that accepts a source string and parses it to construct a JSONArray

package com.restassured.tests;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import io.restassured.http.ContentType;
import static io.restassured.RestAssured.given;

/**
 * 
 * @author Mandeep kaur
 *
 */

public class SamplePostRestTest {

	@Test
	public void createUser_whenSuccess() {


		JSONArray jsonArray = new JSONArray();
		jsonArray.put("Employee");

		JSONObject jo = new JSONObject();
		jo.put("name", "john");
		jo.put("age", "22");
		jo.put("city", "chicago");

		jsonArray.put(jo);

		 given().log().all().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f23")
				.accept(ContentType.JSON)
				.contentType("application/json")
				.and()
				.body(jsonArray.toString())
				.post("https://gorest.co.in/public-api/users")   //hit the post end point
				.thenReturn().asString();

             }
	}

If there will be any issues with JSON Object, We will get below exception:

 

JSON Exception

The JSONException is the standard exception thrown by this package whenever any error is encountered. This is used across all classes from this package. The exception is usually followed by a message that states what exactly went wrong.

Object Mapping:

Lastly, the other method where payloads can be really complexed, we can go for Object Mapping:

We need to follow below steps :

  • Create a Mapping class also called POJO class (Plain Old Java Objects) and this process is called serialization as we are going to convert the object to the body.
  • Create an object of Mapping class
  • Initialise the values available in the mapping class
  • Send the object along with post request

Let’s analyse the below code

{
“name”:”Test Automation”,
“gender”:”Male”,
“email”:”testAutomation6@gmail.com”,
“status”:”Active”
}

To Create the mapping class, I would say go to  JSONToJavaObject, paste the JSON request and get the Mapping class. As done below:

JsonToPOJO

Mapping class

And our createUser Mapping class will look like this:

package com.restassured.vo;

public class createUserDO  {

    private String name;
    private String gender;
    private String email;
    private String status;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

  
}

Now, the second step is to create an object of Mapping class:

  • createUserDO cu = new createUserDO();
  • Initialised the values via setters i.e setName(“Test Automation”) available in the mapping class.
  • and finally, we sent the object in the post call

package com.restassured.tests;


import org.junit.Test;

import com.restassured.vo.createUserDO;

import io.restassured.http.ContentType;
import static io.restassured.RestAssured.given;

/**
 * 
 * @author Mandeep kaur
 *
 */

public class SamplePostRestTest {

	@Test
	public void createUser_whenSuccess() {
	createUserDO cu = new createUserDO();
        cu.setName("Test Automation");
        cu.setGender("Female");
        cu.setEmail("testAutomation25@gmail.com");
        cu.setStatus("Active");
        
		String resp =  given().log().all().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f")
				.accept(ContentType.JSON)
				.contentType("application/json")
				.and()
				.body(cu)
				.post("https://gorest.co.in/public-api/users")   //hit the post end point
				.thenReturn().asString();
		
		System.out.println(resp);

             }
	}

POST Method via Mapping class

Note: if we need to have logs to verify things, we can simply use log().all() and it can display information on a console like below:

Logs on Console

Since we have converted our object to the body, now to validate the response we can use the process called deserialization of response body, which means converting response body to object.

To do that, the first thing is to create a mapping class for response JSON body, you use the same converter as above json2pojo schema and below code how it is to be done:

Deserialization of Response body

package com.restassured.tests;

import static io.restassured.RestAssured.given;

import org.junit.Test;
import org.testng.Assert;

import com.restassured.vo.CreateUserDO;
import com.restassured.vo.ResponseDataObjects;

import io.restassured.http.ContentType;

/**
 * 
 * @author Mandeep kaur
 *
 */

public class SamplePostRestTest {

	@Test
	public void createUser_whenSuccess() {


		CreateUserDO cu = new CreateUserDO();
        cu.setName("Test Automation");
        cu.setGender("Female");
        cu.setEmail("testAutomation1465@gmail.com");
        cu.setStatus("Active");
        
        
      ResponseDataObjects responseDataObjects =  given().log().all().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f")
				.accept(ContentType.JSON)
				.contentType("application/json")
				.and()
				.body(cu)
				.post("https://gorest.co.in/public-api/users")   //hit the post end point
				.thenReturn().as(ResponseDataObjects.class);
		
		      Assert.assertEquals("Test Automation",responseDataObjects.getData().getName());
        
       

             }
	}

Till .post function we were clear what needs to be performed, the next step is thenReturn(), basically, to fetch the response body after that, as (the method )will take the mapping class(ResponseDataObjects ) to deserialize the response and this will return us the object of our mapping class.

And this class can be used to fetch all the information later on, for validations and verification checks.

Our JSON Response

{
    "code": 201,
    "meta": null,
    "data": {
        "id": 1493,
        "name": "Test Automation",
        "email": "testAutomation701@gmail.com",
        "gender": "Male",
        "status": "Active",
        "created_at": "2021-01-07T12:30:58.987+05:30",
        "updated_at": "2021-01-07T12:30:58.987+05:30"
    }
}

And correspondence POJO class:

Note: we need to use @JsonIgnoreProperties(ignoreUnknown=true)as  is applicable at deserialization of JSON to Java object (POJO) only

package com.restassured.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ResponseDataObjects {

    private Integer code;
    private Object meta;
    private Data data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getMeta() {
        return meta;
    }

    public void setMeta(Object meta) {
        this.meta = meta;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }
    
}

package com.restassured.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Data {

	
    private Integer id;
    private String name;
    private String email;
    private String gender;
    private String status;
    private String createdAt;
    private String updatedAt;
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

}

Conclusion:

In this article, we have learnt how to create a payload using various ways such as via string, JSON Object and with object Mapping and how to fetch the response using Deserialization.

Blog Contributors:

Author:  Mandeep Kaur
Mandeep, having 5+ years of Testing experience in automation using Selenium (Java). Expertise in API and Performance testing using JMeter.
https://www.linkedin.com/in/mandeepkaur93
 
Reviewer: Naveen Khunteta 
https://www.linkedin.com/in/naveenkhunteta

HTTP GET method using RestAssured

Get Request And Response
~Image Source : google / sashido.io

  1. Introduction

In this article, we are going to learn about the Get Request in detail, in addition to that, we will also learn how to validate Get Response using RestAssured.

2. Writing Get Method:

Let’s first get started with the simple example – Fetch user details and handle the response:

Assume application is up and running , let’s perform some action using when()

As we can see return type of when() is RequestSender ~https://javadoc.io/doc/io.rest-assured/

and RequestSender Interface Implements Classes as:RequestSpecificationImplTestSpecificationImpl

And in RequestSpecificationImpl class we have below methods such as get() :

Get Methods

Now, Let’s write the Get Method Code:

package com.restassured.testcases;

import static io.restassured.RestAssured.given;

import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.testng.annotations.Test;

/**
 *
 * @author Mandeep Kaur
 *
 */
public class SampleGetTest {

   @Test
    public void getTest() {

        /*
         * given application is up and running and performing the GET request with get(URL)
         * and printing the response 
         *
         */
        Response response =given().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e19f").when()
                .get("https://gorest.co.in/public-api/users");

        //Printing the response
        System.out.println(response.asString());
} }

In the above code ,it is clearly seen that we need header in order to execute get request and it takes key-value pair where Key as authorisation and value as Bearer access_token , get (URL ) and simply print the response and output will be like below and stored in response object.

User details are coming in response what’s more the details of test cases if it’s passed, failed depends on the test case written:

Output on the console and test case is passed and marked as green.

In order to validate status code , below code needs to be executed:

package com.restassured.testcases;

import static io.restassured.RestAssured.given;

import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.apache.http.HttpStatus;
import org.testng.annotations.Test;

/**
 * @author Mandeep Kaur
 */
public class SampleGetTest {

    @Test
    public void getTest() {

        /*
         * given application is up and running and performing the GET request with get(url)
         * with header then status code should be 200 OK
         *
         */
        given().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c12327f409a3228f205e19f").when()
                .get("https://gorest.co.in/public-api/users").then().assertThat().statusCode(HttpStatus.SC_OK);
    }
}

It can be inferred from the above code, if expected code is 200 ok then to validate it , we can use .assertThat and statusCode: HttpStatus.SC_OK without using 200 hard code value as it is, we can use HttpStatus interface variable from package org.apache.http; Similarly, the other statuses from Interface HttpStatus can be fetched like below:

Since, we have validated the status code, Let’s validate the response content also content level validation. Once we received the response , how we will validate that the content is proper or not ?

So, rest assured uses hamcrest Framework for validation.

Inside org.hamcrest package there is a class called Matchers and this class contains all the methods which we can be used for our validation purpose. Below are the methods of Matchers class and you can navigate here to learn more about Matchers class :

Go to Library org.hamcrest > Matchers Class> Methods

Matchers Class under org.hamcrest package

Let’s see the below code:

package com.restassured.testcases;

import static io.restassured.RestAssured.given;

import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.testng.annotations.Test;
import static org.hamcrest.Matchers.*;

/**
 * @author Mandeep Kaur
 */
public class SampleGetTest {
    @Test
    public void getTest() {

        /*
         * given application is up and running and performing the GET request with get(url)
         * Then response should have first email as given below
         */
        given().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f0394504395435").when()
                .get("https://gorest.co.in/public-api/users").
                then().
        body("data.email[0]",equalToIgnoringCase("dhawan_dharani@macejkovic.co"));


    }
}

After hitting the get endpoint , in the body we are validating whether the first email in our response matches to the given email given above in the code and here equalToIgnoringCase comes from the matches Class of hamcrest framework. what it does is where both actual value is equal to expected value irrespective of case.

If both the values matched we will get our test case passed otherwise it will failed as actual value is not getting matched with expected value.

Here’s the json response , for which our code matched perfectly:

Json Response

If not matched the expected value, then we will get the error as below:

and if multiple values to be validated , we can validate like below using comma  :

By now , You must be wondering why did i use data.email[0] for this we need to learn Json Path.

And another way of validating it with hasItem method of hamcrest and if it list needs to be validated then hasItems method will be used:

HasItem Method

hasSize to use when to check how many element a particular json array contains. For Example:

 "data": {
        "data1":[
            "id": 6,
            "name": "Dharani Dhawan",
            "email": "dhawan_dharani@macejkovic.co",
            "gender": "Female",
            "status": "Active",
]}

Now this contains 5 elements so size will be 5.

and in body we can assert :

.body(“data.data1”,hasSize(5));

3. JsonPath Class :

Another way of validating the response with JsonPath Class:

JsonPath class comes from the package

package io.restassured.path.json;

Let’s see the below code to gain deep understanding of it :

Extracting Values from jsonPath

package com.restassured.testcases;

import static io.restassured.RestAssured.given;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import org.testng.Assert;
import org.testng.annotations.Test;
import static org.hamcrest.Matchers.*;

/**
 * @author Mandeep Kaur
 */
public class SampleGetTest {
    @Test
    public void getTest() {

        /*
         * given application is up and running and performing the GET request with get(url)
         * Then response should have first email as given below
         */
       String resp= given().header("authorization", "Bearer 0431655cfe7ba40a791e0ce32d83ad33363348919c11627f409a3228f205e15f84985934850948")
               .accept(ContentType.JSON)
               .when().get("https://gorest.co.in/public-api/users").
                thenReturn().asString();

        JsonPath jsonpath= new JsonPath(resp);
        Assert.assertEquals("dhawan_dharani@macejkovic.co",jsonpath.getString("data.email[0]"));
    }
}

In this code, we fetched the response and store it in string variable.

Now, this variable needs to be passed as a JsonPath constructor, once this is done

we need to use testNg assertions to check our actual response is matched with expected Response.

Actual Value : given above as email

and jsonpath.getString for fetching the value of particular  Key:

data.email[0] : means Json Object starts with label data and email is comes under that label and JsonPath is same like Xpath where we transverse from root element to parent /sibling so on.

Since we need out first value to be matched me just used email[0].

To fetch int or other values it can be fetched like this :


Fetch values from jsonPath

4.Conclusion:

To conclude, We learnt to write our very first get Request Method and tried to validate our response with hamcrest framework and jsonPath Class .

Blog Contributors:

Author:  Mandeep Kaur
Mandeep, having 5+ years of Testing experience in automation using Selenium (Java). Expertise in API and Performance testing using JMeter.
https://www.linkedin.com/in/mandeepkaur93 
 
Reviewer: Naveen Khunteta 
https://www.linkedin.com/in/naveenkhunteta

 

 

 

 

Introduction To Rest Assured

1. Overview :

In this article, we will learn about automating our first API using Rest Assured and various terms linked with API.

2. API

Before proceeding any further , let’s try to understand what is API .

  • API: Application Programming Interface is nothing but public functions that can be called and executed by other programs, these other programs can be programs running in the same computer or those running in a different computer altogether.

Why do we need API or what does it offers :

  1. Abstraction 
  2. Contractual Obligations between client and backend

Let’s try to understand with the help of an example: 

Consider an ATM Machine, you are provided with multiple options such as checking account balance, cash deposit or withdrawal and statement, etc. So here you get all things by a push of few buttons.

Here APIs  play a Key Role in abstracting you from the backend services. Also performing any operations such as cash withdrawal you need to provide your ATM pin and the amount to be withdrawn.

The withdrawal would be allowed only if your pin is correct and have sufficient balance money in your account and it is within the bank transactional limit for the day. So these are some business rules defined and these are nothing but contractual obligations that an API defines and that has to be fulfilled.

So, in short, if both the business and data logic can be re-used in some other application. Then this application is called a web service.

3. Web Service:

It is an interoperable software system designed to support machine-to-machine interaction over a network. The three necessary conditions for any web application to become a web service:

  1. Interoperability: Any Java, DotNet, PHP, or C++ application, etc.., should be able to interact with the web application.
  2. Application-to-application interaction: For example, Jet Airways in its web application uses a different bank’s payment gateway to make payments. Here, banks have extended their applications over the network to be accessed by the jet airways application. Thus, the bank application is acting as a web service.
  3. Communication must be over a network

Now that you have understood the web service and API, the next important term you need to understand is the API endpoint

  1. It is a location from which an API can access the resource that it needs to carry out the functionality.
  2. It is a unique URL for communications between the client-side and server-side.

By now you have understood that web services are capable of communicating with web applications with the help of API endpoints.

Now the question is what does this API endpoint contain that makes any web server understand the requests from the UI and how to respond back?

The two things that make it possible are the request and response that is passed with every API call.

So now it’s imperative to understand how request and response exchange takes place between a client (Browser) and a server

You must have heard the terms SOAP and Rest, Let’s try to understand these first in detail:

4.SOAP Architecture:

So today many applications built in many programming language . For example there is web applications designed in JAVA, some are in .dot net and some in PHP.All these 

  • Application collect and store data, and this data needs to be exchanged among different applications.
  • But this exchange among these heterogeneous applications would be very complex.
  • So, one of the methods to combat this complexity is to bring a common language which is XML i.e. Extensible Markup Language
  • But there for no specific standard on how to use XML across all the programming language for data exchange

So this is where SOAP or Simple Object Access Protocol comes into the picture.

Here are a few reasons for using SOAP architecture:

  1. SOAP is considered a light-weight protocol that is used by applications for data exchange. Also, since SOAP is particularly based on XML, which in itself is a lightweight data exchange language, so it falls in the same category as a protocol.
  2. SOAP is designed to be platform and operating system independent. It can work with programming languages on both Windows and Linux platforms.
  3. It is based on the  HTTP protocol, which is the default protocol used by all web applications. Therefore, there is no customization required to run the web services built on the SOAP protocol to work on the World Wide Web.
  4. It helps in Exposing business functionality over the internet.

 Some limitations with SOAP architecture such as:

  1. The HTTP protocol is not used to its full extent.
  2. A resource representation is done only in XML which is fast, but still can be considered slower than many of its competing technologies such as JSON.
  3. Working with SOAP requires you to write a proper XML structure almost every time, even for extremely simple tasks. This makes your work lengthy and a bit complex.
  4. The above-mentioned limitations can overcome with the introduction of REST(Representational State Transfer) architecture.

5. Rest Architecture:

Let’s look at some characteristics of the REST architecture:

  1. It makes the best use of the HTTP protocol. The request and response sent are proper HTTP request and response. So, the request contains proper HTTP methods while the response contains proper status codes.
  2. It is a style for designing loosely-coupled web services.
  3. It relies on the stateless, client-server protocol, for example, HTTP. So, it does not store any client’s session on the server-side and thus making the REST APIs less complex to develop and maintain.

6. HTTP Protocol:

We have talked a lot about HTTP protocol, but we still don’t know what exactly is this HTTP or even protocol for that matter. 

So, whenever you enter any URL in the address bar of your browser, the browser translates that URL into a request message according to the specified protocol and then sends it to the server.

There are many predefined HTTP methods that can be used while sending HTTP requests.
Most common HTTP methods:

  1. GET :asks the server to retrieve a resource. You can think of a resource as some data or file on the server
  2. POST : asks the server to create a new resource
  3. PUT: asks the server to update a resource
  4. DELETE: asks the server to delete a resource
  5. PATCH: used to update a portion of an already existing resource

Then there are two different categorisation of HTTP methods:

  1. Safe: Safe methods are those that can be cached and prefetched without any repercussions to the resource. This means that there is no change expected in the resource by the client. So, GET is safe, while PUT, POST, DELETE PATCH are not.
  2. Idempotent: An idempotent HTTP method is one that if called many times will provide the same outcome. It does not matter if the method is called only once or multiple times. The result will always be the same. GET, PUT, DELETE methods are idempotent.

The response from the server is accompanied by a status code. This status code is important as it tells the client how to interpret the server response. Here are some of the common status codes –

  1. 1XX – informational
  2. 2XX – success
  3. 3XX – redirection
  4. 4XX – client error
  5. 5XX – server error

Some of the common HTTP status are:

  1. 201 (CREATED)
  2. 200 (OK)
  3. 401 (UNAUTHORIZED)
  4. 403 (FORBIDDEN)
  5. 400 (BAD_REQUEST)
  6. 404 (NOT_FOUND)

Figure: Sending a Request and getting the Response

Further, you can read about what happens when you type a URL and press enter.

https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-and-press-enter-bb0aa2449c1a

Till now we have learned about API, Web Services, SOAP and Rest, HTTP protocol, and methods, Now it’s the perfect time to know about Rest Assured.

7.Rest Assured:

  • REST Assured is an open-source Java library for validation of REST web services.
  • It is flexible and easy to use and supports all the Http Methods such as GET, POST, PUT, etc.
  • It supports BDD (Behavior-Driven Development) by using test notation, Given, When, and Then, which makes the tests human readable.
  • Rest Assured API uses the “Hamcrest” framework for validation.Which we will learn it in detail

8. Creating a simple Rest Assured Program:

Pre-requisites:

JDK 8 , Maven, Eclipse IDE

Let’s get started by creating the first project. Open Eclipse IDE and create a new project.

  1. Click on new –> Maven Project → create simple project → Next

2. Provide group id and Artifact id and click on finish:

Now , configure testNg and Rest Assured library in your pom File:

Once , libraries are added then create a class under src/test/java and create a test method in it:

Here’s the code:



package com.restassured.testcases; import org.testng.annotations.Test; import io.restassured.http.ContentType; import static io.restassured.RestAssured.*; /** * * @author Mandeep Kaur * */ public class SampleTest { @Test public void sampleLogin() { /* * Given application is up and running When i perform the GET request using the * given url Then the status code should be 200 Ok And the response body should * be in Json Format * */ given().accept(ContentType.JSON).header("user-key", "cde67df2673438bb2fae8dc7e205e98451903940394343").when() .get("https://developers.zomato.com/api/v2.1/categories").then().statusCode(200); } }  
  • Before concluding let’s understand few above terms quickly:

    • Rest Assured framework follows the BDD approach.
    • Given keyword defines the precondition
    • When keyword defines the action to be performed
    • Then keyword defines the outcome of the previous step
    • And keyword defines the additional outcome.
    In the above program, the Given application is up and running, the header is passed with a valid user key when performing the GET request using the given URL Then the status code should be 200 Ok And the response body should be in JSON Format (ContentType.Json)

and now run the project using mvn install command and output will be displayed as:

Conclusion:

To encapsulate, we have learned about API and it’s various terminologies, also created our first rest assured test 🙂

Blog Contributors:

Author:  Mandeep Kaur
Mandeep, having 5+ years of Testing experience in automation using Selenium (Java). Expertise in API and Performance testing using JMeter.
https://www.linkedin.com/in/mandeepkaur93
 
Reviewer: Naveen Khunteta 
https://www.linkedin.com/in/naveenkhunteta

 

 

 

 

« Older posts