Page Object Model/Page Factory VS. User Interface Mapping

Page Object Model

Id

Detail

Define

A page object is an object-oriented class that serves as an interface to a page of your AUT. The tests then use the methods of this page object class whenever they need to interact with the UI of that page.

  1. Page Object Model is a design pattern to create Object Repository for web UI elements
  2. Each web page in the application should have corresponding page class

3.  Page class will find the WebElements of that page and also contain Page methods which perform operations on those WebElements

Advantages

The Page Object Design Pattern provides the following advantages

1. There is a clean separation between test code and page specific code such as locators (or their use if you’re using a UI Map) and layout.

2. There is a single repository for the services or operations offered by the page rather than having these services scattered throughout the tests.

 

Basic Rules

There are a few basic rules for getting the desired maintainability of your test code:

  1. Page objects themselves should never make verifications or assertions
  2. A page object does not necessarily need to represent an entire page. The Page Object design pattern could be used to represent components on a page. If a page in the AUT has multiple components, it may improve maintainability if there is a separate page object for each component.

 User Interface Mapping

Id

Detail

Define

A User Interface (UI) Map is a mechanism that stores all the locators for a test suite in one place for easy modification when identifiers or paths to UI elements change in the application under test (AUT).

Advantages

To summarize, a UI Map has two significant advantages

  1. Using a centralized location for UI objects instead of having them scattered throughout the script. This makes script maintenance more efficient.
  2. Cryptic HTML Identifiers and names can be given more human-readable names improving the readability of test scripts.

 

 Page Factory

Id

Detail

Define

  1. Page Factory is an inbuilt Page Object Model concept for Selenium WebDriver which is very optimized
  2. Separation of Page Object Repository and Test Methods
  3. Page Factory Class provide @FindBy annotation to find WebElemnts
  4. @FindBy can accept tagName, partinalLinkText, name, LinkText, id, css, className & xpath as attributes

    @FindBy(how = How.CSS, using = "input[id='submit.button']")

    WebElement loginLocator;

   

    public Login() {

        PageFactory.initElements(this.driver, this);

    }

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值