Where we learn technology

Category: Uncategorised (Page 1 of 7)

Selenium & Java Training Course Content – Regular Evening Batch (29th Oct 2020)

Selenium & Java Training – Regular Evening Batch (29th Oct 2020)

Hi Folks,

Please enrol ASAP.  🙂 This time I’m introducing some amazing content on Java, Selenium and some different approaches on Framework Designing. This will be very different from my YouTube channel.

After a very high demand on Java+Selenium training,

Here I’m going to start next batch (4:30 PM to 5:30 PM IST) from 29th Oct 2020.

Thanks for registering “Selenium & Java Sessions” By Naveen AutomationLabs. As per the further registration process, you need to pay the 3000 INR (50 USD for US Folks) as a registration fee.

Next Batch Starting from: 29th Oct, 2020 
Duration: 9 weeks

Registration Fee: 3000 INR (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 (Goto Meeting)

ClassesTimings: (3 Days in a week – Monday – Wed – Friday)

  • 4:30 PM IST (Indian Time)
  • 7 AM EST (US Time)


 Payment Options:

Here I’m sharing the bank account details. Please send me the screenshot of receipt once you make the payment without fail. 
You need to mail me at : naveenanimation20@gmail.com

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) Or Xoom.

Bank Details:


To Account: 256010100095576
Account Type : Savings

Bank Name: AXIS BANK


Branch Location: PALANPUR, GUJRAT

IFSC Code: UTIB0000256

PayPal Payment: 

  • If you are paying through PayPal, You need to pay 330 USD (10 USD will be the PayPal Fee).
  • Use this PayPal id: https://paypal.me/NaveenKhunteta

For Candidates in India:

You can also make the payment via Tez (Google Pay) :
UPI to this number: +91-9902233400. 
UPI: naveenanimation20@okicici 
OR Google IDnaveenanimation20@gmail.com


  • There will be 2 demo sessions. In case If you don’t like the sessions or if you want to leave. Full Registration amount will be transferred back to you after 2 sessions.
  • After 2 demo sessions, pending amount must be paid.
  • I’ll share the meeting id with URL to join the session before the training 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 WebDriver 3 and Java. We focus on the basics first and then move towards the advance concepts of Selenium, Java and framework development.

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
  • Wrapper Classes
  • String Manipulation
  • Collections Basics (Array List, HashMap, Set)
  • Interview Questions

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

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) Action 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
• Finding Coordinates of a Web Object
• Drag and Drop Action

  • 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

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
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
• Different types of Automation Framework
• What is Data Driven Framework

  • What is Hybrid Framework
  • What is Page Object Model Design Pattern with Page Factory and Non Page Factory with OOP concepts
  • Interview Questions 

16) Real Time Live PROJECT – 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.

  • 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, Emailable Report and PDF Report
    • Generating web portal reports sing T-Esults (new web reporting tool)

17) How to create project JARs (Generic Jars used by different teams)

  • Normal library JAR
  • Runnable JAR
  • Run JAR with Command Line Arguments
  • How to add generic JAR as a build path in your Java Project
  • How to add generic JAR as maven dependency in POM.xml in your Maven Project
  • How to create libraries with FAT Jars

18) Dev Ops & Continuous Integration

  • Jenkins Setup Basics
  • Running Script via Jenkins
  • Jenkins PipleLine – Classic View
  • Jenkins PileLine – Blue Ocean
  • Jenkins PipeLine Syntax
  • Jenkins Report Generation using Extent Report, Allure, TestNG Report and Tesults Report
  • Git WebHook with NgRok to trigger the build automatically
  • GIT Repo/GIT HUB
  • Learn how to use commit command
  • What is cloning in GIT
  • My First Code Check-in to GIT
  • GIT PULL Request Process
  • GIT CheckOut
  • GIT Branching
  • GIT Merge
  • GIT Commit
  • GIT Push, Fetch & Pull Commands
  • GIT Clean
  • Centralized Version Control System vs Distributed Verison Control System

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
  • Zalenium – Docker GRID Setup
  • Zalenium Live Preview
  • Zalenium Test Dashboard
  • Selenoid Dockerized GRID

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


21) Life Time Access on all recorded Videos, Free Code Repos, and Java Code
22) Free Cucumber Videos only

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: Can I get all the recordings for these sessions?
Ans: Yes, you will get all the recordings daily basis for the specific topic.

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 QA to Automation QA. After this training, you will become an expert in automation. 

Q4: Can I justify my automation experience, after this training?
Ans: Yes, training is designed like this only. You can easily justify 2 to 6 yrs of exp in automation after this training.

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 6-7 weeks. It can take more than this also.

Q7: Who will be the trainer?
Ans: Only Naveen from Naveen AutomationLabs.

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.

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. 

Q10: Will assignments be shared for covered topics?
Ans: for almost every topic, I have assignment and it will be shared daily basis. You need to submit the assignment daily basis and feedback will be shared with you regular 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 relate the topics with real time scenarios only, how exactly test automation and any system works 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.

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 (+10 mins extra sometimes).
  10. We will have two demo sessions, if you don’t want to continue with the sessions, registration money will be refunded back.
  11. After demo sessions, pending amount has to be paid as per the fee structure.

“Happy Learning” 🙂

Naveen AutomationLa

Please follow and like us:

NoSuchElementException and NotFoundException in Selenium || Common Exceptions in Selenium

There is no ElementNotFoundException as such in selenium, if you are talking in #Selenium context. We have NotFoundException which is extended by :
Direct Known Subclasses as:
NoAlertPresentException, NoSuchCookieException, NoSuchElementException, NoSuchFrameException, NoSuchWindowException

Please refer this Java API Doc: https://jar-download.com/artifacts/org.seleniumhq.selenium/selenium-api/3.141.59/documentation

NoSuchElementException extends NotFoundException” 


NotFoundException extends WebDriverException“. 

This is thrown when???
1. Element could not be found in the DOM – or may it never. exists.
2. The page is still being loaded and you’ve already finished your WebElement search
3) AJAX Element has not returned yet on the page

If you encounter this exception, you may want to check the following:
>Check your selector used in your find_by…
>Element may not yet be on the screen at the time of the find operation, (webpage is still loading) apply WebDriverWait() for an element to be appeared on the page. 

Exceptions that may happen in all the webdriver code.

Common Exceptions in Selenium:

exception selenium.common.exceptions.ElementClickInterceptedException


The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked.

exception selenium.common.exceptions.ElementNotInteractableException


Thrown when an element is present in the DOM but interactions with that element will hit another element do to paint order

exception selenium.common.exceptions.ElementNotSelectableException (msg=Nonescreen=Nonestacktrace=None)[source]

Thrown when trying to select an unselectable element.

For example, selecting a ‘script’ element.

exception selenium.common.exceptions.ElementNotVisibleException


Thrown when an element is present on the DOM, but it is not visible, and so is not able to be interacted with.

Most commonly encountered when trying to click or read text of an element that is hidden from view.

exception selenium.common.exceptions.ErrorInResponseException


Thrown when an error has occurred on the server side.

This may happen when communicating with the firefox extension or the remote driver server.

exception selenium.common.exceptions.ImeActivationFailedException


Thrown when activating an IME engine has failed.

exception selenium.common.exceptions.ImeNotAvailableException


Thrown when IME support is not available. This exception is thrown for every IME-related method call if IME support is not available on the machine.

exception selenium.common.exceptions.InsecureCertificateException


Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.

exception selenium.common.exceptions.InvalidArgumentException


The arguments passed to a command are either invalid or malformed.

exception selenium.common.exceptions.InvalidCookieDomainException 


Thrown when attempting to add a cookie under a different domain than the current URL.

exception selenium.common.exceptions.InvalidCoordinatesException


The coordinates provided to an interactions operation are invalid.

exception selenium.common.exceptions.InvalidElementStateException


Thrown when a command could not be completed because the element is in an invalid state.

This can be caused by attempting to clear an element that isn’t both editable and resettable.

exception selenium.common.exceptions.InvalidSelectorException


Thrown when the selector which is used to find an element does not return a WebElement. Currently this only happens when the selector is an xpath expression and it is either syntactically invalid (i.e. it is not a xpath expression) or the expression does not select WebElements (e.g. “count(//input)”).

exception selenium.common.exceptions.InvalidSessionIdException


Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it’s not active.

exception selenium.common.exceptions.InvalidSwitchToTargetException


Thrown when frame or window target to be switched doesn’t exist.

exception selenium.common.exceptions.JavascriptException


An error occurred while executing JavaScript supplied by the user.

exception selenium.common.exceptions.MoveTargetOutOfBoundsException


Thrown when the target provided to the ActionsChains move() method is invalid, i.e. out of document.

exception selenium.common.exceptions.NoAlertPresentException


Thrown when switching to no presented alert.

This can be caused by calling an operation on the Alert() class when an alert is not yet on the screen.

exception selenium.common.exceptions.NoSuchAttributeException


Thrown when the attribute of element could not be found.

You may want to check if the attribute exists in the particular browser you are testing against. Some browsers may have different property names for the same property. (IE8’s .innerText vs. Firefox .textContent)

exception selenium.common.exceptions.NoSuchCookieException


No cookie matching the given path name was found amongst the associated cookies of the current browsing context’s active document.

exception selenium.common.exceptions.NoSuchElementException


Thrown when element could not be found.If you encounter this exception, you may want to check the following:

  • Check your selector used in your find_by…
  • Element may not yet be on the screen at the time of the find operation, (webpage is still loading) see selenium.webdriver.support.wait.WebDriverWait() for how to write a wait wrapper to wait for an element to appear.

exception selenium.common.exceptions.NoSuchFrameException


Thrown when frame target to be switched doesn’t exist.

exception selenium.common.exceptions.NoSuchWindowException


Thrown when window target to be switched doesn’t exist.

To find the current set of active window handles, you can get a list of the active window handles in the following way:

exception selenium.common.exceptions.RemoteDriverServerException


exception selenium.common.exceptions.ScreenshotException


A screen capture was made impossible.

exception selenium.common.exceptions.SessionNotCreatedException


A new session could not be created.

exception selenium.common.exceptions.StaleElementReferenceException


Thrown when a reference to an element is now “stale”.

Stale means the element no longer appears on the DOM of the page.Possible causes of StaleElementReferenceException include, but not limited to:

  • You are no longer on the same page, or the page may have refreshed since the element was located.
  • The element may have been removed and re-added to the screen, since it was located. Such as an element being relocated. This can happen typically with a javascript framework when values are updated and the node is rebuilt.
  • Element may have been inside an iframe or another context which was refreshed.

exception selenium.common.exceptions.TimeoutException


Thrown when a command does not complete in enough time.

exception selenium.common.exceptions.UnableToSetCookieException


Thrown when a driver fails to set a cookie.

exception selenium.common.exceptions.UnexpectedAlertPresentException


Thrown when an unexpected alert is appeared.

Usually raised when when an expected modal is blocking webdriver form executing any more commands.

exception selenium.common.exceptions.UnexpectedTagNameException


Thrown when a support class did not get an expected web element.

exception selenium.common.exceptions.UnknownMethodException


The requested command matched a known URL but did not match an method for that URL.

exception selenium.common.exceptions.WebDriverException

(msg=Nonescreen=Nonestacktrace=None)[source] vBase webdriver exception.


Reference taken from: 



Naveen AutomationLabs

Please follow and like us:


Please follow and like us:

3. How to write Selenium WebDriver Test with TestNG – Maven Project

You might be wondering when Selenium WebDriver itself is such a powerful web automation tool, why do we need TestNG. Well, the fact is that it is indeed a powerful automation tool, however it lacks various capabilities such as ability to group, parameterize, sequence and generate reports. This is where tools like TestNG and JUnit come into play. These tools have inherent capabilities to organize and execute scripts as per the need of different test phases, arrange and execute them in a logical sequence as needed per the business requirements.

In the previous section, we have seen how to use TestNG with simple Java project. In this section let us see with Selenium WebDriver project in Eclipse IDE.

Step1. Go to Eclipse IDE, right click on the Package Explorer, select New and Click on Project option.

Step 2. You will see New Project window, select Maven Project and click on Next button

Step3. Select ” Create a simple project (skip archetype selection)” and click on next button.

Step 4: Provide Group ID, Artifact ID, Name and Description as shown in the below screenshot

Step 5. Click on Finish button.

Maven creates the Project structure as shown in the below screenshot

Step 6. Maven reads pom.xml file and executes the project. Pom.xml is the file which contains project and configuration details such as dependencies, build directory, plugins, goals etc. to build the maven project. So we need to add TestNG and Selenium WebDriver jar files’ details in the dependency section as shown below.

You might notice that we have added one more dependency i.e, webdrivermanager. Let’s quickly see what is the WebDriverManager.

You probably know that in Selenium Webdriver, to use browsers such as Chrome, Firefox, Safari etc., first we need to download the driver i.e, a binary file that allows WebDriver to handle browsers. And we should set the path of these files in the code as shown below



In addition to this, we need to check manually when the new version of the driver binaries released. WebDriver manger has automated this process for us to overcome this manual process. We just have to add the dependency and include the code as shown below.



Step 6. We also need to add TestNG library in the Java build path. Let’s do it.In the Package Explorer, select the project, right click on it. Then go to Properties->Java Build Path->Add Library-> Select TestNG-> Next->Finish.

Note : All dependency jar files are downloaded in “Maven Dependencies” folder in the Project directory.

Step7. Now we are good to write the code. Remember all our TestNG, test related code goes in the src/test/java folder. We can either create a new Java class or a TestNG Class.

To create Java class, right click on the folder-> new ->Java class->Give a class name and click on Finish.

To Create TestNG class,right click on the folder->Others->select TestNG class as shown below

Provide the details and select the required annotations in the New TestNG class window as shown below and click on Finish button.

If you have created Java project, you need to write the required annotation along with Selenium Webdriver methods. If you have created the TestNG class along with required annotations, you might have to rearrange the annotations as per your testing needs. In additon to this, you can also include other annotations if needed. Let’s see a sample code.

Step 1. Create two class files called SeleniumTestNGDemoTest.java and BaseTest.java files .Write codes to verify “Sign in” link and “Google Search “button in the Google webpage.

Step2: Go to BaseTest.java, write Selenium WebDrivercode code to initialize the WebDriver, launch the browser and navigate to the Google Website. These are pre-test condition to execute the test cases. Also write one post-test condition, i’e, to close the browser as shown below.

Step 3: Go to SeleniumTestNGDemoTest.java, write the selenium code for the above mentioned test cases. Refer the below screenshot for the same.

Step 4. Create a testng.xml file as shown below and run the testng.xml file. If you don’t know how to execute the TestNG projects, please refer my earlier article.

In the Console, you can see that it is executed successfully.

Also, you can check status of the test cases that are passed, failed or skipped in the Results tab as shown below.

The report generated will be saved in the index.html under test-output folder. You can refresh and check this folder. In the next article, we will see how to prioritize the test cases and then understand the TestNG reports in detail.

Please follow and like us:

1. What is TestNG and How to install it

TestNG is an open source Java testing framework which is distributed under the Apache Software License and is readily available for download. TestNG is inspired by JUnit which was the most widely used testing framework for Java applications. Despite being an easy to use and straightforward framework, JUnit has its own limitations which gave rise to TestNG. It was created by Cedric Beust to simplify a broad range of testing needs.

TestNG takes care of needs across testing lifecycle including unit testing, functional testing and Integration testing etc. The “NG” in TestNG stands for ‘Next Generation” implying that, is a next generation testing framework and it is more powerful than JUnit when it comes to parallel testing, reporting and managing dependencies. This article makes an effort to elaborate the above said aspects in further details.

TestNG Features

Some of the key features include

  • Control over test execution with powerful annotations
  • Help achieve parallel testing
  • Ability to set dependencies on methods
  • Support for parameterize
  • Support for Data Driven Testing using data providers
  • Generate test logs across tests
  • Excellent reporting ability
  • Can be integrated with Eclipse, Maven, Jenkins etc

How to get started with TestNG

Before learning TestNG, you should have the basic knowledge of automation testing and any automation tools that supports Java. Here we are going to learn TestNG framework with Selenium WebDriver hence knowledge of the same is essential.

TestNG can be integrated with Simple Java project or Maven Integrated Java Project. Before we start writing the automation test scripts, let’s see the steps involved to automate the testcases and its execution.

Step 1: Write the business logic of your test

Step 2: Insert TestNG Annotations in your test code to control the flow of test cases to follow the business logic

Step 3: Validate test cases with TestNG assertion

Step 4: Add details of testcases in the testNG.xml file

Step 5: Run your Tests

Step 6: View the results in HTML reports

We are going to create Java project and integrate TestNG, hence make sure Jdk1.8 and Eclipse IDE is installed in your machine. Note:The example shown are written and executed in Windows 10, 64 bit system.

How to install TestNG

Generally, TestNG comes as jar files. There are two ways of installing TestNG in Eclipse.

  1. Directly from the Eclipse Marketplace
  2. Through Help -> Install New Software option

How to Install TestNG through Market place

This option is available in new versions of Eclipse. This is the recommended method as it is the easiest method to install TestNG compared to the other installation method.

Step 1: Launch Eclipse IDE, click on the Help menu, select the “Eclipse Market place…” option in the dropdown

Step 2:  In Eclipse Marketplace dialog box, you see “Find” input field, enter “TestNG” and hit the enter key to search.

Step3: Now, you’ll see “Install” button for all search results. Click on “Install” button of TestNG for Eclipse as shown in the above screenshot and proceed with the installation . It will take some time ..so be patient ;).

Step 4: Click on “I accept the terms of the license agreement” and then click Finish.

Step 5: If you see a security warning, ignore it by clicking the OK button. 

Now, wait for the installation to finish.

Step 6: After the installation, Eclipse will prompt you to restart, just click Yes.

How to verify TestNG Installation

There are multiple ways to verify the successful installation of TestNG.

One way is to launch the Eclipse, navigate to “Preferences” from “Window” option in the menu bar, see TestNG listed. Refer the below screenshot for the same.

Another way to verify is to right click on the project in Project Explorer section, you will see TestNG listed as shown below.

How to install TestNG Plugin in Eclipse using the “Install New Software…” feature.

Step1. Launch the Eclipse IDE, Go to Help menu and click on “Install New Software”..

Step2. It will launch an Install window as shown below.

Step 3: You need to copy the build path url from the site https://github.com/cbeust/testng-eclipse. So, go to the site and copy the stable release url from Update sites’ section as shown below

Step 4: Come back to the Eclipse IDE and paste it in “Work With” input box. You will see that the TestNG option listed as shown below. Select the TestNG option and click on Next button and continue the installation process, accept the licence agreement and click on Finish button. If you see a security warning, just ignore and accept it by clicking the OK button. Once the installation is complete, Eclipse will prompt you to restart it. Click on Yes to restart.

Step 5: After the restart, to verify the successful installation of TestNG plugin follow the same procedures mentioned in the First method of installation.

 In the next section, we will see how to write TestNG code to build Test framework with simple Java and Selenium WebDriver project with Eclipse IDE.

Please follow and like us:

2. How to Create TestNG Class with Different Annotations

As mentioned in earlier section, TestNG can be integrated with Simple Java project or Maven Integrated Java Project. First, we will see with a simple Java project.

  1. Go to the Eclipse IDE, create a new Java project. Right click on the Package Explorer panel, Select New option and then click on Project. You will see a New Project Wizard, select Java Project listed under Java Section, click on Next button, now you will be asked to provide the project name. Write the project name in Project Name input box and click on Finish Button.
  2. You will see that project is created in the Package Explorer along with default “src” folder in it.
  3. At this stage, we need to Integrate TestNG plug-in to the current project. So right click on the Project Name, go to Properties-> Java Build path-> Click on Add Library option, select TestNG and click on “Next” button and “Finish”. Finally click on “Apply and Close” button to close the Properties window.
  4. Create a new package under src folder. Then create a new Java class without the Main method.
  5. Write the below code in it.
TestNG Annotations

After writing the codes, you will notice that TestNG annotations are underlined with red, it means that the Eclipse IDE doesn’t know which library to refer for, just place the cursor over it, and select import from “org.testng.annotations” as show in the below screenshot to import.

How to use TestNG Annotations

An annotation is a tag that provides additional information about the class or method. It is represented by ‘@’ prefix. TestNG uses these annotations to help create a framework. Below listed are some of the most widely used annotations in test framework.


The test scripts (test methods) where the main business logic resides, should be tagged with @Test annotation. It has various attributes based on which the method can be reformed and executed which we will see later. By default, these @Test methods are executed in alphabetical order.


A Test suite consists of multiple classes, this annotated method will be run before all the tests methods of all the classes implemented in the test suite. This annotation marks the entry point of execution. @BeforeSuite annotation in TestNG can be used to perform the needed generic functions like setting properties in configuration files and starting Selenium driver or initializing the logging procedure which are necessary. It is executed only once in the test execution hierarchy



This annotated method will be run before your first @Test annotated method in your class (and after @BeforeSuite if used  in the code) You can use this annotation to launch the browser, setting up your own customized profile for your browser etc. that are must to run the test scripts. This annotated method is executed once for every tests defined in the <test> tag in testng.xml file. (We will see what Testng.xml file in further section)



This annotated method will be run before any @Test method of that class is executed but after @BeforeTest method. We can use this to go to the application website or anything that you would like perform/ set before executing the test scripts.



This annotated method will be run before every @test annotated method. You can use it to login to the application before executing your tests.


This annotated method will be run after every @test annotated method. You can use it to logout from the application after executing your tests. It can also be used to take screenshot of every method execution



This annotated method will be run after all @Test methods of the class is executed but before @BeforeTest annotated method is run. This annotation can be used to delete cookies or some that you want to do at class level



This annotated method will be run after all test method belonging to the classes inside the <test> tag in testNG.xml file is run. It can be used to close the browser or anything that you want to do after the execution of all test methods.


This annotated method will be run after all tests in this suite have run. This annotation can be used to clean up the processes before completing off your tests when you have multiple classes in functioning.


You can customize all the above annotated methods as per you testing needs. To summarize these, @Before annotated method behave as pre-test conditions, @After annotated methods behave as post-test conditions and @Test annotated method is where the business logic resides and it is executed in the alphabetical order by default

When you run the above code, the output will be as shown in the below screenshot


As explained in the above section, first all pre-test conditions are executed.

@BeforeSuite annotated method is executed only once before all other annotated methods’ execution.  

@BeforeTest:  It is executed only once since we have created only one   <test > tag defined. It is explained in the further section.

 @BeforeClass:  It is executed before any @Test annotated method execution of the current class. In the above example there is only one class so only once it is executed, next

@BeforeMethod, before every @Test annotated method. In our example we have two @Test annotated methods so twice it is executed.

Next, @Test annotated methods are executed.

Finally, post-test conditions are executed in the below order

@AfterMethod: It is executed after every @Test annotated method. In our example there are two @Test annotated methods so twice it is executed after each testcases

@AfterClass: After all the @Test annotated methods of the current classes are executed. In the above example only one class is defined so only once it is executed

@AfterTest: It is executed after all @Test annotated method from all classes have been executed

@AfterSuite is executed in the end.

Let’s see how  to execute this project in the next section.

Please follow and like us:

5. How to Run TestNG Class from Command Line and Eclipse

Let’s understand how the TestNG project can be executed. Since it doesn’t contain Java main method, it can’t be run as Java Application. We can run in the below two ways.

1. Through Eclipse IDE

2. Through Command line.

How to run TestNG project from Eclipse IDE

We can use one of the below mentioned methods.

  • Run as TestNG Test
  • Create Testng.xml and execute it

Run as TestNG Test:

  1. From the editor’s area: Right click on the editor’s area where the TestNG code is written, select Run As-> TestNG Test.
  2. From the Package Explorer: This method can be used to run single or multiple classes.

Go to Package Explorer in the Eclipse IDE ->select single/ multiple classes/ test package, right click on it -> Choose Run As->TestNG Test

3. From the Menu bar, Click on Run button .

Refer below screenshot for the above-mentioned methods.

Different ways to run TestNG project

When TestNG file/files are run in the above-mentioned ways, TestNG creates a default Testng.xml file and executes the test.  This default testng.xml can be located in two places.

  1. In the index.html file
  2. Under test-Ouput folder

1. TestNG will generate a default report that can be viewed in index.html file present under test-Output folder. Right click on the Project in the Package explorer and Refresh after TestNG project is executed. Copy the path of the index.html file and open it in the browser. [Note: We will go through index.html file in detail in the further section]

2. Right click on the Project in the Package explorer and click on Refresh after TestNG project is executed. Go to test-Output folder under Project directory. Expand it, then go to old-Default suite. You will see textng.xm.html file. Open it and check the code.

How to run TestNG project through command line.

In order to run Testng.xml file through command line, we need testng.jar and jcommander.jar files.  These jar files can be searched and downloaded from https://mvnrepository.com/.

Once it is downloaded, place it in “libs” folder under your Eclipse project directory. Before we run it, we need to compile our project. The compiled code can be found in “bin” folder under the project directory. We can execute the TestNG project in two ways. Either you set the class path first for lib and bin folder and then execute or combine both the commands in one step. Both the ways are shown below. So go to command prompt,

Step 1.  set classpath=[Project Folder]\bin;[Project Folder]\libs\*   

Step 2. java org.testng.TestNG testng.xml


Step 1. java -cp “.\bin;.\libs\*” org.testng.TestNG testng.xml

For example:  Navigate to project folder and type the below command

or navigate to project folder and the type the below command

Text Box: java -cp “.\bin;.\libs\*” org.testng.TestNG testng.xml

We can execute multiple testng.xml files just by appending it.


Please refer below screenshot for command line execution

In the next section, we will see how to create Testng.xml and execute it through Eclipse IDE .

Please follow and like us:

4. How to create and run TestNG project through Testng.xml

TestNG.xml file is a configuration file that helps organizing our tests. It allows testers to create and handle multiple test classes, define test suites and tests. Also, we can achieve parallel testing and parameterize test cases through Testng.xml which we will see later sections. Let’s see how to create tesng.xml file.

Go to project folder, right click on it, select TestNG option listed and click on Convert to TestNG as shown in the below screenshot.

On clicking “Convert to TestNG” option, you will see the below dialog box as shown in the below screenshot. Click on Finish button to finish .

Here is the sample of testng.xml file

Example 1:

Let us understand the different components of testng.xml file.

Suite: A Suite is represented by one XML file. It can contain one or more tests and is defined by the <suite> tag. Example:

verbose: It is used to log the execution details in the console. The value should be 1-10. As you increase the value of verbose attribute, you will get more detailed log in the console window.

Test: A Test is represented by <test> and can contain one or more TestNG classes.Example:

Class : TestNG class is a Java class that contains at least one TestNG annotation. It is represented by the <class> tag and can contain one or more test methods.Example :

Test Method: A Test method is a Java method annotated by @Test methods in the source file. Example:

Example 2

We can specify package names instead of class names: In this example, TestNG will look at all the classes in the package “test.sample” and will run only classes that have TestNG annotations.

How to Run Testng.xml in the Eclipse IDE

Select the testng. xml file in the package explorer, right-click on it, move to Run As option and then select TestNG suite option.

How to create multiple classes, packages and execute TestNG suite

  1. Launch the Eclipse IDE, create a Java project, create two packages under src folder. Say Basic Features and TestUtility.
  2. Create three classes in Basic Features package say LoginPageTest.java, HomePageTest.java and SearchPageTest.java
  3. Create one class in TestUtility package, say BaseTest.java
  4. Write the below codes in the classes
  5. Create Testng.xml and execute it.

Refer below folder structure in the Package Explorer

Now, write the below codes in the respective class files as shown below

Next, create testng.xml file as shown below

Now, execute the testng.xml file and you will see the below output

Let’s have a look at the execution order in the above project.

First, all pre-test Conditions are executed . In the above example, it is defined in BasePageTest.java and is executed in the below mentioned order

  1. @BeforeSuite: It is executed before executing any of the @Test annotated methods and any @Before annotated methods. It is executed only once.
  2. @BeforeTest: It is executed before all the classes included in the test included in  <test> tag. In the above case it is <test thread-count=“5” name=“Test”>. Thread count is used in parallel testing, it can be excluded.
  3. @BeforeMethod: It is executed before every @Test annotated method in all the classes that have extended BasePageTest class.

Next, @Test annotated method where the business requirement resides are executed. That is after pre-test annotated methods,

  • @Test: @Test annotated methods are executed as per the classes organized in Testng.xml. In the above case, it will execute first all @Test annotated methods in SearchPageTest.java, then from LoginPageTest.java and finally HomePageTest.java. And within the class, it is executed in alphabetical order.

Then, all post-test conditions are executed

  • @AfterMethod: It is executed after every @Test annotated method. In our example there are four @Test annotated methods so it is executed after each @Test methods.
  • @AfterTest: It is executed after all @Test annotated method from all classes have been executed

 It is not necessary to use all the annotations, So based on testing needs these annotations, classes and tests should be defined.

View the test execution results in the Results of running suite tab

We can create multiple testng.xml files for different test phases and create test suite as per the testing needs. Example: RegressionSuite.xml, SmokeTestSuite.xml etc.

In the next section, we will see how to create Maven project and integrate TestNG with Selenium Webdriver code.

Please follow and like us:

What is OAuth 2.0?

What is OAuth 2.0?

First Question that will come to everyone’s mind “is it Authentication or Authorization”?

Well, it is Authorization, to be precise Authorization between services. Now next doubt that would arise is why the services would be communicating with each other, generally in API environment what happens is, it is actually user and API exchange information or vice-versa. 

But hold on, when there are two or more services along with the user involved in communication, then there should be some way so that the services should know each other at least an introduction!! to whom they are dealing with and this introduction happens on behalf of user with the help of “Token” and this whole process in known as OAuth2.0.


Let say there are three entities user, App1 and App2 User wants to use one feature of App1 but that feature in App1 will require some input data(say file, videos etc). This data is actually stored in App2(suppose in google drive). 

Now the user wants that App1 should directly communicate with App2 take the required data from there and use it, what the user is actually interested is “End Result”.

Given the scenario now we can dive in to more technical aspect.
Resource Owner -> The user is resource owner.

Client – > App1 is the client because it is actually using some features/services of App2.

Client ID -> It is the unique identifier by which App2 remembers App1. It is used to keep track of an api because there may be times when App2 will be communicating with different api’s.

Client Secret -> It is like a password of a particular client ID store at App2.
Resource Server -> It is primarily used to generate Access token requested by any api so that particular api can use this access token in order to request to access a resource from target api.

AuthServer -> what is this??? his name was mentioned in our example. This server is actually sometimes is part of Resource Server. It is responsible to generate the “Token” used for Authorization. 

Auth server is sometimes part of api and sometimes not it totally depends upon the architecture of api. As a real time example of this – When we try to login to any website using google/facebook login, in backend this auth server is used for Authorization purpose.

Grant Types – There are generally two types of grant types in OAuth2.0

a) Authorization Code – The Authorization code grant type is used by confidential and public clients to exchange an Authorization code for an access token.

b) Client Credentials – It is used by clients to obtain an access token outside of context of a user. This is typically used by clients to access resources about themselves rather than to access a user’s resources.

c) Refresh Token – The Refresh Token grant type is used by clients to exchange a
refresh token for an access token when the access token has expired. This allows clients to continue to have a valid access token without further interaction with the user.

d) Device Flow – It is used for Authorizing apps on devices that don’t have a web

In this blog we will be discussing Authorization code grant type which is most widely used in

Please refer below diagram for the same:


  1. User sends a request to App1 to do some task.
  2. App1 need some input from App2 so it will contact Authorization
    server (Auth Server) to have access for the same.
  3. Auth Server will say to App1 wait who are you I don’t you, let me
    check with my user.
  4. User will check the message from Auth Server and will say yes it is
    a legit request from App1 please do the needful.
  5. Auth Server will say Ok, fine and it will give one “Auth Token” to
    App1. One important point here “By Auth token App1 is only
    authorized to use the neccessary functionality/api of App2 i.e. to get
    some data required here, it is not entitled to access anything extra”.
  6. App1 – Thanks for the Authorization Auth Server, App1 will contact
    Resource Server in order to have Access token to access a particular
    resource in App2.
  7. Resource Server – Sure, please find your “Access Token”.
  8. Using this access token App1 will sent a request to App2.
  9. App1 will finally get the response from App2.
    ** Here Access Token for more security point of view else it can happen that these auth
    token can be used by some other applications.
    ** The Access token are not mandatory to use in Javascript applications.

Real time examples of OAuth2.0:

Let us go to bookmyshow.com and try to sign in –

Here we are seeing an option like Connect via Google or Connect via Facebook. Suppose if we click on Connect via Google, will be redirected to –

This is all based on OAuth2.0 mechanism, if we sign in to our google account we are giving access to bookmyshow to use our information. Similarly there are other websites which works on the same principle like makemytrip, cleartrip etc.

What are Bearer Tokens?
Bearer token are simple String which are used for authentication for API’s request and is sent in Header of a request. These tokens doesn’t require cryptographically signing of each request (this is the case in OAuth1.0) and are more easier way of making api request. 

As bearer token consists of simple plain text and can be vulnerable to security that’s why it is always recommended that API requests consisting of bearer token should be made over an HTTPS protocol.

Difference between OAuth1.0 and OAuth2.0?

We will see differences between these Authorization framework on basis of below

  1. Authentication & Signatures:
    OAuth1.0 is based on cryptographically signing each request and is more complex to implement. OAuth2.0 is based on bearer token and is easier to implement.
  2. User Experience and alternative token issuance options:
    Initially OAuth1.0 has three flows i.e for web apps, desktop clients and mobile devices. But it was turned out that it only worked out fine with web apps. OAuth2.0 address this problem by introducing multiple flows called the grant types.
  3. ** Flows – The methods of obtaining an access token are called flows.
  4. Performance: OAuth2.0 performs better than OAuth1.0 when the api is scaled up.
  5. Bearer Tokens:
    OAuth1.0 have two parts in access token a public and a private string. Private string was used while signing the request, never sent across to other api.
    OAuth2.0 has only Bearer token which is a simple public string which is used in API requests.
  6. Life of Tokens:
    OAuth1.0 had long-lived tokens.
    OAuth2.0 have short-lived tokens and a long lived refresh token (this allows apps to obtain new access tokens without involving the user again).
Hope you got idea about OAuth2.0 Authorization.


Naveen AutomationLabs

Blog Contributors:

This blog is written by Shobhit Varshney.


Reviewer: Naveen Khunteta

Please follow and like us:
« Older posts