Imagine that you have a site that has a number of different pages that you need to test. This is quite common for a number of sites. We can create an object that represents the page and then pass the Selenium object in the programming language. So let us now create our first Page Object against the home page.
Create a new Java class in IDEA called HomePage.
Import the relevant packages for the tests to run.
We will now need a constructor to handle Selenium. You may want to make it go to the home page when it is instantiated too. An example of this can be seen as follows:Chapter2.java BestPractises3.java
If you create these three files you will see it pass. The test is a lot more succinct and easier to maintain.
What just happened?
In this section we had a look at creating tests using the Page Object design pattern.This allows us to create objects in a programming language and then pass the Selenium object to it to drive the browser. This creates a really nice DSL that allows all parties in the development cycle to understand. We create a Java object for each of the pages that we want to work against on the site. We then just instantiate the class to work against that page.
When we are moving between pages you click on a link and the method controlling the page transition will return an object representing a new page.
The objects will not hold the asserts; this should always be done within the tests.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.