Selenium Java Framework from Scratch

Selenium Java Framework from Scratch

Step by Step for Beginners

What you’ll learn

  • Create automation frameworks using Selenium in Java

  • Understand the basic concepts and working of Selenium

  • Understand the basic concepts of Automation Frameworks

  • Will be able to create test automation framework step by step
Requirements
  • No prior knowledge is required
  • Designed for complete Beginners

Setup Selenium Java Project in Eclipse

Today we will learn…

1. What are the Prerequisites

2. How to create maven project in Eclipse

3. Add dependencies in pom.xml

4. Make project ready for adding Selenium scripts

You can follow this on…

Windows and Mac

Prerequisites

Java is installed on your system

Eclipse is installed on your system

Maven is installed on your system

REFERENCES : 

Install Java on windows – https://www.youtube.com/watch?v=FqpmH8MVO6A

Install Java on Mac – https://www.youtube.com/watch?v=NSvtis2fGlA

Eclipse – Getting Started – https://www.youtube.com/watch?v=rpB1WWqZ6HQ

https://mvnrepository.com

http://www.seleniumhq.org

Today we will learn…

1. How to add Firefox browser driver – Geckodriver

2. Run a test on Firefox browser

To add gecko driver exe

System.setProperty(“webdriver.gecko.driver”,” path to gecko driver exe”);

OR

System.setProperty(“webdriver.firefox.marionette”, “path to gecko driver exe”);

You can follow this on…

Windows and Mac

References:

https://github.com/mozilla/geckodriver/releases

Today we will learn…

How to add Chrome Driver

Run a test on Chrome browser

Step 1 :

Download ChromeDriver

Step 2 :

Add ChromeDriver in Eclipse

Step 3 :

Add script in Eclipse (IDE)

System.setProperty(“webdriver.chrome.driver”,”location of chromedriver”);

Webdriver driver = new ChromeDriver();

Step 4 :

Run and Validate

helpful tips

Always check the latest version of chrome driver from

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

If you give the location of folder having driver in environment variable Path, then you don’t have to set

System.setProperty(“webdriver.chrome.driver”,”location of chromedriver”);

REFERENCES

https://chromedriver.storage.googleapis.com/index.html

https://www.seleniumhq.org/download/

http://chromedriver.chromium.org/downloads

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

How to run Selenium tests on Internet Explorer

Today we will learn

1. How to add IE Driver

2. Run a test on IE browser

Step 1 : 

Download IEDriver

Step 2 : 

Add IEDriver in Eclipse

Step 3 : 

Add script in Eclipse (IDE)

System.setProperty(“webdriver.ie.driver”,”location of iedriver”);

Webdriver driver = new InternetExplorerDriver();

Step 4 : 

Run and Validate

helpful tips

Always check the latest version of ie driver from 

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

If you give the location of folder having driver in environment variable Path, then you don’t have to set

System.setProperty(“webdriver.ie.driver”,”location of iedriver”);

REFERENCES

https://www.seleniumhq.org/download/

https://selenium-release.storage.googleapis.com/index.html  

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

How to find Web Elements Locators in Selenium

Today we will learn…

1. How to find web elements

2. How to use Selenium functions to locate elements

helpful

tips

Step 1 : 

Inspect Web Element

Step 2 : 

Check any of these locators

id

name

cssSelector

xPath

className

linkText

partialLinkText

tagName

Step 3 : 

Use locators with Selenium func.

findElement

findElements

helpful

tips

Check your selected locator in different browsers

Can take help of tools for generating xpath and cssSelectors

Can ask developers to provide unique ids to every web element for easy identification and location

REFERENCES

https://www.w3schools.com/xml/xpath_examples.asp

http://xmltoolbox.appspot.com/xpath_generator.html

How to create FIRST SELENIUM TEST in Java

Today we will learn…

1.How to create a test in Selenium

2.Run and Validate

Step 1 : 

Create a Java Class

Step 2 : 

Add code to open browser

Step 3 : 

Add code for browser actions

Step 4 : 

Close Browser

Step 5 : 

Run and Validate

helpful tips

Check your selected locator in different browsers

Can take help of tools for generating xpath and cssSelectors

Whenever you face any error:

Check the logs

Copy the error on Google and search

What is Page Object Model (POM) | How to create POM in Selenium

Today we will learn…

1. What is POM – Page Object Model

2. How to implement POM

What is POM

===========

Design Principle

Create separate Object Repository to store object locators

For each web page there should be a separate page class

The page class will have all object locators and preferably action methods for the corresponding page

Step 1 : 

Create a class for each web page

Step 2 : 

Add object locators

Step 3 : 

Create class for test

Step 4 : 

Refer objects from page classes

Step 5 :

Run and validate

Benefits of POM

=============

Test Objects and Functions are separated for easy maintenance and keeping the code clean

Objects are kept separated from test scripts and can be used multiple times in multiple tests

Every unique object locator is created only once

Easy Maintenance and Less Rework

What is TestNG | How to install TestNG for Selenium 

Today we will learn…

1. What is TestNG

2. How to install TestNG in eclipse

3. How to add TestNG libraries in Selenium Project

What is TestNG

TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit. 

Makes test creation, execution and reporting efficient

Uses annotations like

@BeforeTest, @AfterTest, 

@BeforeSuite, @AfterSuite

@BeforeMethod, @AfterMethos

@BeforeClass, @AfterClass

NG = Next Generation

Step 1 : 

Add TestNG plugin in Eclipse

Step 2 : 

Add TestNG libraries

Step 3 : 

Validate

Advantages of TestNG

Makes test creation, execution and reporting efficient

Helps in Grouping of tests

Helps in Prioritizing of tests

Parallel execution

Reporting

REFERENCES

https://testng.org/doc/index.html

https://github.com/cbeust/testng-eclipse/

https://en.wikipedia.org/wiki/TestNG

https://mvnrepository.com/

Selenium What is testng.xml | How to create testng.xml

Today we will learn…

What is testng.xml file

How to create and run with testng.xml

Practical Example

What is testng.xml

Configuration file in TestNG

Used to provide test execution settings

e.g.

include tests, class, packages etc

exclude tests, class, package etc

set test dependency

set test priorities

pass parameters to test methods

run in parallel

Used to control execution of TestNG tests

Today we will learn…

1. What is Extent Report

2. How to add Extent Reports in Selenium

helpful tips

What is Extent Reports | How to use Extent Reports in Selenium

What is Extent Report

HTML Reporting library

ExtentReports is an open-source reporting API for Java and .NET. It creates an interactive HTML report of your test session.

ExtentReports also has a commercial version (Pro)

How to implement ExtentReports in Selenium Java

Step 1 : 

Add ExentReports libraries in project

You can add jars or maven dependency

Step 2 : 

Create references of ExtentReport func

Step 3 : 

Use ExtentReport functions

log, info, pass, fail etc

Step 4 : 

Run and Validate

REFERENCES

http://extentreports.com/docs/versions/3/java/#basic-example

REFERENCES

http://extentreports.com/docs/versions/3/java/#basic-example

Description

This course if for complete Beginners.
You can take this course without any prior knowledge on Selenium, Java or Automation.

We will go very basic, Step-by-Step and learn – How to create a Selenium Java Framework

In this course we will learn:

  • How to setup a Selenium Java Project from scratch

  • How to create Selenium Java scripts

  • How to run tests on different browsers – Chrome, Firefox, IE

  • How to find Web Locators

  • How to setup Page Object Model – POM

  • How to use TestNG

  • How to use Extent Reports

  • How to create Data Driven tests using Excel file

  • How to do Logging

  • How to do Exception Handling

  • How to run tests on Headless Browser

  • and much much more…

Let’s Get Started…

Who this course is for:
  • Beginners in Selenium
  • Anyone who wants to learn to create Selenium Java Framework from scratch

Redeem Coupon

We will be happy to hear your thoughts

Leave a reply

iLearnE