0% found this document useful (0 votes)
9 views67 pages

Free Code Camp (Document) - Selenium Page Object Model

The document provides a comprehensive guide on using Selenium with Java, focusing on the Page Object Model design pattern. It covers the setup of Selenium projects, creating tests, and working with various web elements, along with the benefits of automation and the architecture of Selenium components. Additionally, it includes tutorials on handling specific scenarios such as alerts, frames, and dynamic waits.

Uploaded by

Rajesh Bijili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views67 pages

Free Code Camp (Document) - Selenium Page Object Model

The document provides a comprehensive guide on using Selenium with Java, focusing on the Page Object Model design pattern. It covers the setup of Selenium projects, creating tests, and working with various web elements, along with the benefits of automation and the architecture of Selenium components. Additionally, it includes tutorials on handling specific scenarios such as alerts, frames, and dynamic waits.

Uploaded by

Rajesh Bijili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Selenium With

Java Using
Page Object Model
Selenium
Components
 Selenium WebDriver

 Selenium IDE

 Selenium Grid

Rex Jones II
Selenium Architecture
(Direct)
Selenium Client & Browser Web
WebDriver Language Bindings Drivers Browsers

Java
ChromeDriver Chrome
C#
GeckoDriver Firefox
Python
SafariDriver Safari
Ruby
EdgeDriver Edge
JavaScript

Client Server
Rex Jones II
Selenium With Java
Using Page Object Model

 Programming Language = Java

 Test Framework = TestNG

 Design Pattern = Page Object Model

Rex Jones II
Selenium
Automation Benefits
 Open Source

 Implement With CI/CD

 Support Multiple Browsers & OS

 Helps With Regression Testing

Rex Jones II
Application Features

2 6
1

4
7
8
3

9 5 10
Rex Jones II
4 Tutorial
Parts
1) Set Up Project & Create 1st Selenium Test

2) Create Page Object Model

3) Working With WebElements

4) Selenium Interfaces & Methods For Unique Situations

Rex Jones II
4 Tutorial
Parts
1) Set Up Project & Create 1st Selenium Test

2) Create Page Object Model

3) Working With WebElements

4) Selenium Interfaces & Methods For Unique Situations

Rex Jones II
Selenium With Java
Using Page Object Model

 Set Up Project

 First Selenium Test

Rex Jones II
Set Up
Project
Rex Jones II
First Selenium
Test

Rex Jones II
4 Tutorial
Parts
✓ Set Up Project & Create 1st Selenium Test

2) Create Page Object Model

3) Working With WebElements

4) Selenium Interfaces & Methods For Unique Situations

Rex Jones II
Selenium With Java
Using Page Object Model

 Introduce Page Object Model

 Create Page Object Model

 Create Test Using Page Object Model

Rex Jones II
Introduce Page
Object Model

Rex Jones II
Page Object Model
Design Pattern

Web
Pages

Page Objects Test


(Variables & Methods) Scripts

Variables & Methods are stored


separate from Test Scripts Rex Jones II
Benefits of
Page Object Model

 Code Reusability - reuse code in multiple locations in


our program

 Code Readability - code is easy to follow

 Code Maintainability - take less time to make a


change to our code

Rex Jones II
Web Pages Home Page Help Page

Page Objects HomePage HelpPage


(Variables & Methods) (Variables & Methods)

Test Scripts Test Script 1 Test Script 2 Test Script 3


(Access PO Methods) (Access PO Methods) (Access PO Methods)
Rex Jones II
Web Pages Home Page Help Page

Page Objects HomePage HelpPage


(Variables & Methods) (Variables & Methods)

Test Scripts Test Script 1 Test Script 2 Test Script 3


(Access PO Methods) (Access PO Methods) (Access PO Methods)
Rex Jones II
Web Pages

BasePage
(Common To All PO’s)

Page Objects

BaseTest
(Common To All Tests)
(setUp & tearDown)

Test Scripts
Rex Jones II
Web Pages Home Page Help Page

BasePage
(Common To All PO’s)

Page Objects HomePage HelpPage


(Variables & Methods) (Variables & Methods)

BaseTest
(Common To All Tests)
(setUp & tearDown)

Test Scripts Test Script 1 Test Script 2 Test Script 3


(Access PO Methods) (Access PO Methods) (Access PO Methods)
Rex Jones II
Create Page
Object Model

Rex Jones II
BasePage

Rex Jones II
LoginPage

Rex Jones II
ProductsPage

Rex Jones II
Create Test
Using Page Object

Rex Jones II
WebDriver
API’s

Rex Jones II
BaseTest

Rex Jones II
Login Test
Script

Rex Jones II
Products Test
Script

Rex Jones II
4 Tutorial
Parts
✓ Set Up Project & Create 1st Selenium Test

✓ Create Page Object Model

3) Working With WebElements

4) Selenium Interfaces & Methods For Unique Situations

Rex Jones II
Selenium With Java
Using Page Object Model
 Scroll Using JavaScriptExecutor

 Work With Radio Buttons

 Work With Checkboxes

 Work With Drop Downs

 Work With Tables

 Work With Links

 Work With Dates


Rex Jones II
Scroll Using
JavaScriptExecutor

Rex Jones II
Work With
Radio Buttons
Rex Jones II
Work With
Checkboxes
Rex Jones II
Work With
Tables
Rex Jones II
Work With
Links
Rex Jones II
Work With
Drop Downs
Rex Jones II
Work With
Dates
Rex Jones II
4 Tutorial
Parts
✓ Set Up Project & Create 1st Selenium Test

✓ Create Page Object Model

✓ Working With WebElements

4) Selenium Interfaces & Methods For Unique Situations

Rex Jones II
Selenium With Java
Using Page Object Model
 How To Take A Screenshot

 How To Handle A Modal

 Switch To Alerts

 Switch To Frames

 Switch To Windows

 Dynamic Wait Statements

 Selenium Interactions
Rex Jones II
Take A
Screenshot
Rex Jones II
How To
Handle A Modal
Rex Jones II
Switch To
Alerts
Rex Jones II
Alert
Types

1. Information Alert

2. Confirmation Alert

3. Prompt Alert

Rex Jones II
Information
Alert
Rex Jones II
Confirmation
Alert
Rex Jones II
Prompt
Alert
Rex Jones II
Switch To
Frames
Rex Jones II
Switching To
Frames

1. Switch To Frames Using String

2. Switch To Frames Using Index

3. Switch To Frames Using WebElement

Rex Jones II
Switch To Frame
Using String
Rex Jones II
Switch To Frame
Using Index
Rex Jones II
Switch To Frame
Using WebElement

Rex Jones II
Switch To
Windows
Rex Jones II
Switch Method
Types For Windows

Method Description
getWindowHandle() Get the current window handle

getWindowHandles() Get the current window handles

switchTo().window() Switch focus between windows

Rex Jones II
Dynamic Wait
Statements
Rex Jones II
Selenium Wait
Methods
Method Description
Thread.sleep() (Not a Selenium Wait Method) Causes execution to
sleep for a certain number of milliseconds
Page Load Timeout Sets the wait time for a page to load before throwing
an error
Script Timeout Sets the wait time for JavaScript to execute before
throwing an error
Implicit Wait Instructs WebDriver to wait for all WebElements
connected to the driver
Explicit Wait Pauses execution until time has expired or an
expected condition is met via WebDriverWait class
Fluent Wait A specialization used by Explicit Wait and extended
by the WebDriverWait class
Rex Jones II
Explicit
Wait
Rex Jones II
Fluent
Wait
Rex Jones II
Implicit
Wait
Rex Jones II
Page Load
& Script Timeout
Rex Jones II
Selenium
Interactions
Rex Jones II
Selenium
Interactions

 Simulate Mouse Movements

 Simulate Keyboard Events

Rex Jones II
Simulate
Mouse
Movements
Rex Jones II
Simulate
Keyboard Events

Rex Jones II
4 Tutorial
Parts
✓ Set Up Project & Create 1st Selenium Test

✓ Create Page Object Model

✓ Work With WebElements

✓ Selenium Interfaces & Methods For Unique Situations

Rex Jones II
Rex Jones II
Rex Jones II

You might also like