SlideShare a Scribd company logo
1 of 5
Download to read offline
Page Object Model and
Implementation in Selenium
In testing department of today’s IT sector, Automation has a significant role. IT companies
are leaning towards automation testing because there are endless advantages of automating an
application. For programming language, automation gives flexibility. There are distinct types
of frameworks that companies use for automating their applications. Some of which are
mentioned below, and one of which is Page Object Model also popular as POM.
● Page Object Model (POM)
● Hybrid
● Data Driven
● Keyword Driven
POM is a type of framework which is very easy to understand and easy to implement while
making architecture of any automation process. It basically enhances the test maintenance
and reduces the possibility of duplication of code, which is very concerned thing in test
automation. In other words POM is a structured base object repository design.
In POM we create a page class for each corresponding web page in the application. Now, the
page class that we have created contains all the web-elements of that page and also that
methods that we will perform on those web-elements, so the name that we give to a method
should be according to its functionality, for example- for a log-in page, the name of the
method can be login() which only has few elements like user-name, password, log-in button,
forget password link, etc. and methods like passing strings in the field and clicking the
buttons.
For making a robust and easy to maintain framework we use POM with data driven by
collating excel with POM. The best combination would be POM with data driven through
excels and run test cases through TestNG
Below mentioned the flowchart will make it clearer to understand:
Implementation Example in Selenium
1. Create a new package file as Practice; we will be creating different packages for Page
Objects, Utilities, Test Data, Test Cases and Modular actions. It is always recommended
to use this structure, as it is easy to understand, simple to use and easy to maintain.
2. Create a new class file and refer the name to the actual page from the test object. In our
case it is Home Screen and Login Screen.
3. Create a static method for each element in Home Screen. Each method will have an
argument (driver) and returns a value (element).
package Practice;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class Home_Screen {
private static WebElement element = null;
public static WebElement MyAccount(WebDriver driver){
element = driver.findElement(By.id(“id”));
return element;
}
public static WebElement LogOut(WebDriver driver){
element = driver.findElement(By.id(“logout”));
return element;
}
}
4.Reason of passing driver as argument selenium is able to locate the element on the browser
(driver). Element is returned so that action can be performed on it.
5.Method is declared as public static so that it can be called in any other method without
creating instance of the class.
6.Follow same rule for creating another class LogIn Screen.
package Practice;
import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class LogIn_Screen {
private static WebElement element = null;
public static WebElement UserName(WebDriver driver){
element = driver.findElement(By.id(“id”));
return element;
}
public static WebElement Password(WebDriver driver){
element = driver.findElement(By.id(“id”));
return element;
}
public static WebElement LogIn(WebDriver driver){
element = driver.findElement(By.id(“id”));
return element;
}
}
7. Now create a new class which will be our test case, let’s say we are creating it in package
called Framework by name POM.
package Framework;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
// Import package pageObject.*
import pageObjects.Home_Screen;
import pageObjects.LogIn_Screen;
public class POM{
private static WebDriver driver = null;
public static void main(String[] args) {
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(“http://www.store.demoqa.com”);
// Use page Object library now
Home_Screen.MyAccount(driver).click();
LogIn_Screen.UserName(driver).sendKeys(“testuser_1”);
LogIn_Screen.Password(driver).sendKeys(“Test@123”);
LogIn_Screen.LogIn(driver).click();
System.out.println(” Login Successfully, now it is the time to Log Off buddy.”)
Home_Screen.LogOut(driver).click();
driver.quit();
}
}
8.You will notice that once you type HomeScreen in your test script and the moment you
press dot, all the methods in the Home Page will display. We can expose methods in order to
reduce duplicated code. We are able to call these method multiple times. This will ensure a
better maintainable test code, because we only have to make adjustments and improvements
in one particular place.
**Implementation reference is taken from: toolsqa.com.

More Related Content

What's hot

Selenium test automation
Selenium test automationSelenium test automation
Selenium test automationSrikanth Vuriti
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Edureka!
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and SeleniumKarapet Sarkisyan
 
Prueba De Aplicaciones Web con Selenium 2 y WebDriver
Prueba De Aplicaciones Web con Selenium 2 y WebDriverPrueba De Aplicaciones Web con Selenium 2 y WebDriver
Prueba De Aplicaciones Web con Selenium 2 y WebDriverDavid Gómez García
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriverAnuraj S.L
 
Handling iframes using selenium web driver
Handling iframes using selenium web driverHandling iframes using selenium web driver
Handling iframes using selenium web driverPankaj Biswas
 
Packages,static,this keyword in java
Packages,static,this keyword in javaPackages,static,this keyword in java
Packages,static,this keyword in javaVishnu Suresh
 
Karate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingKarate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingRoman Liubun
 
Python selenium
Python seleniumPython selenium
Python seleniumDucat
 

What's hot (20)

Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Selenium with java
Selenium with javaSelenium with java
Selenium with java
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automation
 
Webdriver.io
Webdriver.io Webdriver.io
Webdriver.io
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Prueba De Aplicaciones Web con Selenium 2 y WebDriver
Prueba De Aplicaciones Web con Selenium 2 y WebDriverPrueba De Aplicaciones Web con Selenium 2 y WebDriver
Prueba De Aplicaciones Web con Selenium 2 y WebDriver
 
Selenium
SeleniumSelenium
Selenium
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Selenium Automation Framework
Selenium Automation  FrameworkSelenium Automation  Framework
Selenium Automation Framework
 
Handling iframes using selenium web driver
Handling iframes using selenium web driverHandling iframes using selenium web driver
Handling iframes using selenium web driver
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Hybrid framework
Hybrid frameworkHybrid framework
Hybrid framework
 
Packages,static,this keyword in java
Packages,static,this keyword in javaPackages,static,this keyword in java
Packages,static,this keyword in java
 
Karate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingKarate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testing
 
Python selenium
Python seleniumPython selenium
Python selenium
 

Similar to Page Object Model and Implementation in Selenium

Introduction to Selenium and Test Automation
Introduction to Selenium and Test AutomationIntroduction to Selenium and Test Automation
Introduction to Selenium and Test AutomationAhmed Mubbashir Khan
 
Using Page Objects
Using Page ObjectsUsing Page Objects
Using Page ObjectsGetch88
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ideTestertester Jaipur
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in Sandeep Tol
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driverPankaj Biswas
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with exampleshadabgilani
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development IntroductionGanuka Yashantha
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Joe Ferguson
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksTsimafei Avilin
 

Similar to Page Object Model and Implementation in Selenium (20)

Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Introduction to Selenium and Test Automation
Introduction to Selenium and Test AutomationIntroduction to Selenium and Test Automation
Introduction to Selenium and Test Automation
 
Using Page Objects
Using Page ObjectsUsing Page Objects
Using Page Objects
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
 
Selenium
SeleniumSelenium
Selenium
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Protractor framework architecture with example
Protractor framework architecture with exampleProtractor framework architecture with example
Protractor framework architecture with example
 
Qa process
Qa processQa process
Qa process
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Qa process
Qa processQa process
Qa process
 
Test automation
Test  automationTest  automation
Test automation
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Codeception
CodeceptionCodeception
Codeception
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricks
 

More from Zoe Gilbert

SAP HANA Implementation A Complete Guide.pdf
SAP HANA Implementation A Complete Guide.pdfSAP HANA Implementation A Complete Guide.pdf
SAP HANA Implementation A Complete Guide.pdfZoe Gilbert
 
HIPAA Compliance Testing In Software Applications.pdf
HIPAA Compliance Testing In Software Applications.pdfHIPAA Compliance Testing In Software Applications.pdf
HIPAA Compliance Testing In Software Applications.pdfZoe Gilbert
 
Checklist For Modernizing Your Legacy Application.pdf
Checklist For Modernizing Your Legacy Application.pdfChecklist For Modernizing Your Legacy Application.pdf
Checklist For Modernizing Your Legacy Application.pdfZoe Gilbert
 
Ad Hoc Testing: Everything You Need To Know
      Ad Hoc Testing: Everything You Need To Know       Ad Hoc Testing: Everything You Need To Know
Ad Hoc Testing: Everything You Need To Know Zoe Gilbert
 
Eliminate OTT Platform Flaws with Quality Engineering.pdf
Eliminate OTT Platform Flaws with Quality Engineering.pdfEliminate OTT Platform Flaws with Quality Engineering.pdf
Eliminate OTT Platform Flaws with Quality Engineering.pdfZoe Gilbert
 
Best Tools for Website Accessibility Testing in 2022.pdf
Best Tools for Website Accessibility Testing in 2022.pdfBest Tools for Website Accessibility Testing in 2022.pdf
Best Tools for Website Accessibility Testing in 2022.pdfZoe Gilbert
 
What are the Advantages and Disadvantages of Microservices?
What are the Advantages and Disadvantages of Microservices? What are the Advantages and Disadvantages of Microservices?
What are the Advantages and Disadvantages of Microservices? Zoe Gilbert
 
Embedded Testing Vs Software Testing – Key Difference.pdf
Embedded Testing Vs Software Testing – Key Difference.pdfEmbedded Testing Vs Software Testing – Key Difference.pdf
Embedded Testing Vs Software Testing – Key Difference.pdfZoe Gilbert
 
Why is Low Code Automation Testing Gaining Popular.pdf
Why is Low Code Automation Testing Gaining Popular.pdfWhy is Low Code Automation Testing Gaining Popular.pdf
Why is Low Code Automation Testing Gaining Popular.pdfZoe Gilbert
 
Logistics Automation to Strengthen Process Efficiency.pdf
Logistics Automation to Strengthen Process Efficiency.pdfLogistics Automation to Strengthen Process Efficiency.pdf
Logistics Automation to Strengthen Process Efficiency.pdfZoe Gilbert
 
Accelerating Digital Transformation in the BFSI Sector.pdf
Accelerating Digital Transformation in the BFSI Sector.pdfAccelerating Digital Transformation in the BFSI Sector.pdf
Accelerating Digital Transformation in the BFSI Sector.pdfZoe Gilbert
 
Hyperautomation.pdf
Hyperautomation.pdfHyperautomation.pdf
Hyperautomation.pdfZoe Gilbert
 
What is the Right Approach to QA Outsourcing.pdf
What is the Right Approach to QA Outsourcing.pdfWhat is the Right Approach to QA Outsourcing.pdf
What is the Right Approach to QA Outsourcing.pdfZoe Gilbert
 
AI in Cloud Computing
AI in Cloud ComputingAI in Cloud Computing
AI in Cloud ComputingZoe Gilbert
 
Boast the Potential of DevOps with CI CD
Boast the Potential of DevOps with CI CDBoast the Potential of DevOps with CI CD
Boast the Potential of DevOps with CI CDZoe Gilbert
 
What is Sanity Testing.pdf
What is Sanity Testing.pdfWhat is Sanity Testing.pdf
What is Sanity Testing.pdfZoe Gilbert
 
Tackle Business Risks with Continuous Testing.pdf
Tackle Business Risks with Continuous Testing.pdfTackle Business Risks with Continuous Testing.pdf
Tackle Business Risks with Continuous Testing.pdfZoe Gilbert
 
Guide to Successful AI.pdf
Guide to Successful AI.pdfGuide to Successful AI.pdf
Guide to Successful AI.pdfZoe Gilbert
 
Top Software Testing Models for Customer Satisfaction.pdf
Top Software Testing Models for Customer Satisfaction.pdfTop Software Testing Models for Customer Satisfaction.pdf
Top Software Testing Models for Customer Satisfaction.pdfZoe Gilbert
 
Compliance testing or conformance testing
Compliance testing or conformance testingCompliance testing or conformance testing
Compliance testing or conformance testingZoe Gilbert
 

More from Zoe Gilbert (20)

SAP HANA Implementation A Complete Guide.pdf
SAP HANA Implementation A Complete Guide.pdfSAP HANA Implementation A Complete Guide.pdf
SAP HANA Implementation A Complete Guide.pdf
 
HIPAA Compliance Testing In Software Applications.pdf
HIPAA Compliance Testing In Software Applications.pdfHIPAA Compliance Testing In Software Applications.pdf
HIPAA Compliance Testing In Software Applications.pdf
 
Checklist For Modernizing Your Legacy Application.pdf
Checklist For Modernizing Your Legacy Application.pdfChecklist For Modernizing Your Legacy Application.pdf
Checklist For Modernizing Your Legacy Application.pdf
 
Ad Hoc Testing: Everything You Need To Know
      Ad Hoc Testing: Everything You Need To Know       Ad Hoc Testing: Everything You Need To Know
Ad Hoc Testing: Everything You Need To Know
 
Eliminate OTT Platform Flaws with Quality Engineering.pdf
Eliminate OTT Platform Flaws with Quality Engineering.pdfEliminate OTT Platform Flaws with Quality Engineering.pdf
Eliminate OTT Platform Flaws with Quality Engineering.pdf
 
Best Tools for Website Accessibility Testing in 2022.pdf
Best Tools for Website Accessibility Testing in 2022.pdfBest Tools for Website Accessibility Testing in 2022.pdf
Best Tools for Website Accessibility Testing in 2022.pdf
 
What are the Advantages and Disadvantages of Microservices?
What are the Advantages and Disadvantages of Microservices? What are the Advantages and Disadvantages of Microservices?
What are the Advantages and Disadvantages of Microservices?
 
Embedded Testing Vs Software Testing – Key Difference.pdf
Embedded Testing Vs Software Testing – Key Difference.pdfEmbedded Testing Vs Software Testing – Key Difference.pdf
Embedded Testing Vs Software Testing – Key Difference.pdf
 
Why is Low Code Automation Testing Gaining Popular.pdf
Why is Low Code Automation Testing Gaining Popular.pdfWhy is Low Code Automation Testing Gaining Popular.pdf
Why is Low Code Automation Testing Gaining Popular.pdf
 
Logistics Automation to Strengthen Process Efficiency.pdf
Logistics Automation to Strengthen Process Efficiency.pdfLogistics Automation to Strengthen Process Efficiency.pdf
Logistics Automation to Strengthen Process Efficiency.pdf
 
Accelerating Digital Transformation in the BFSI Sector.pdf
Accelerating Digital Transformation in the BFSI Sector.pdfAccelerating Digital Transformation in the BFSI Sector.pdf
Accelerating Digital Transformation in the BFSI Sector.pdf
 
Hyperautomation.pdf
Hyperautomation.pdfHyperautomation.pdf
Hyperautomation.pdf
 
What is the Right Approach to QA Outsourcing.pdf
What is the Right Approach to QA Outsourcing.pdfWhat is the Right Approach to QA Outsourcing.pdf
What is the Right Approach to QA Outsourcing.pdf
 
AI in Cloud Computing
AI in Cloud ComputingAI in Cloud Computing
AI in Cloud Computing
 
Boast the Potential of DevOps with CI CD
Boast the Potential of DevOps with CI CDBoast the Potential of DevOps with CI CD
Boast the Potential of DevOps with CI CD
 
What is Sanity Testing.pdf
What is Sanity Testing.pdfWhat is Sanity Testing.pdf
What is Sanity Testing.pdf
 
Tackle Business Risks with Continuous Testing.pdf
Tackle Business Risks with Continuous Testing.pdfTackle Business Risks with Continuous Testing.pdf
Tackle Business Risks with Continuous Testing.pdf
 
Guide to Successful AI.pdf
Guide to Successful AI.pdfGuide to Successful AI.pdf
Guide to Successful AI.pdf
 
Top Software Testing Models for Customer Satisfaction.pdf
Top Software Testing Models for Customer Satisfaction.pdfTop Software Testing Models for Customer Satisfaction.pdf
Top Software Testing Models for Customer Satisfaction.pdf
 
Compliance testing or conformance testing
Compliance testing or conformance testingCompliance testing or conformance testing
Compliance testing or conformance testing
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

Page Object Model and Implementation in Selenium

  • 1. Page Object Model and Implementation in Selenium In testing department of today’s IT sector, Automation has a significant role. IT companies are leaning towards automation testing because there are endless advantages of automating an application. For programming language, automation gives flexibility. There are distinct types of frameworks that companies use for automating their applications. Some of which are mentioned below, and one of which is Page Object Model also popular as POM. ● Page Object Model (POM) ● Hybrid ● Data Driven ● Keyword Driven POM is a type of framework which is very easy to understand and easy to implement while making architecture of any automation process. It basically enhances the test maintenance and reduces the possibility of duplication of code, which is very concerned thing in test automation. In other words POM is a structured base object repository design. In POM we create a page class for each corresponding web page in the application. Now, the page class that we have created contains all the web-elements of that page and also that methods that we will perform on those web-elements, so the name that we give to a method should be according to its functionality, for example- for a log-in page, the name of the method can be login() which only has few elements like user-name, password, log-in button, forget password link, etc. and methods like passing strings in the field and clicking the buttons.
  • 2. For making a robust and easy to maintain framework we use POM with data driven by collating excel with POM. The best combination would be POM with data driven through excels and run test cases through TestNG Below mentioned the flowchart will make it clearer to understand: Implementation Example in Selenium 1. Create a new package file as Practice; we will be creating different packages for Page Objects, Utilities, Test Data, Test Cases and Modular actions. It is always recommended to use this structure, as it is easy to understand, simple to use and easy to maintain. 2. Create a new class file and refer the name to the actual page from the test object. In our case it is Home Screen and Login Screen. 3. Create a static method for each element in Home Screen. Each method will have an argument (driver) and returns a value (element). package Practice; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;
  • 3. import org.openqa.selenium.WebElement; public class Home_Screen { private static WebElement element = null; public static WebElement MyAccount(WebDriver driver){ element = driver.findElement(By.id(“id”)); return element; } public static WebElement LogOut(WebDriver driver){ element = driver.findElement(By.id(“logout”)); return element; } } 4.Reason of passing driver as argument selenium is able to locate the element on the browser (driver). Element is returned so that action can be performed on it. 5.Method is declared as public static so that it can be called in any other method without creating instance of the class. 6.Follow same rule for creating another class LogIn Screen. package Practice; import org.openqa.selenium.*; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class LogIn_Screen { private static WebElement element = null; public static WebElement UserName(WebDriver driver){ element = driver.findElement(By.id(“id”)); return element; }
  • 4. public static WebElement Password(WebDriver driver){ element = driver.findElement(By.id(“id”)); return element; } public static WebElement LogIn(WebDriver driver){ element = driver.findElement(By.id(“id”)); return element; } } 7. Now create a new class which will be our test case, let’s say we are creating it in package called Framework by name POM. package Framework; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; // Import package pageObject.* import pageObjects.Home_Screen; import pageObjects.LogIn_Screen; public class POM{ private static WebDriver driver = null; public static void main(String[] args) { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(“http://www.store.demoqa.com”); // Use page Object library now Home_Screen.MyAccount(driver).click();
  • 5. LogIn_Screen.UserName(driver).sendKeys(“testuser_1”); LogIn_Screen.Password(driver).sendKeys(“Test@123”); LogIn_Screen.LogIn(driver).click(); System.out.println(” Login Successfully, now it is the time to Log Off buddy.”) Home_Screen.LogOut(driver).click(); driver.quit(); } } 8.You will notice that once you type HomeScreen in your test script and the moment you press dot, all the methods in the Home Page will display. We can expose methods in order to reduce duplicated code. We are able to call these method multiple times. This will ensure a better maintainable test code, because we only have to make adjustments and improvements in one particular place. **Implementation reference is taken from: toolsqa.com.