What's the correct Protractor's syntax for Page Objects?

后端 未结 2 623
自闭症患者
自闭症患者 2021-02-06 15:28

I\'ve come across different types of syntax for Protractor\'s Page Objects and I was wondering, what\'s their background and which way is suggested.

This is the official

2条回答
  •  半阙折子戏
    2021-02-06 15:58

    Page Object Model framework becomes popular mainly because of:

    1. Less code duplicate
    2. Easy to maintain for long
    3. High readability

    So, generally we develop test framework(pom) for our convenience based on testing scope and needs by following suitable framework(pom) patterns. There are NO such rules which says that, strictly we should follow any framework.

    NOTE: Framework is, to make our task easy, result oriented and effective

    In your case, 1st one looks good and easy. And it does not leads to confusion or conflict while in maintenance phase of it.

    Example: 1st case-> element locator's declaration happens at top of each page. It would be easy to change in case any element locator changed in future.

    Whereas in 2nd case, locators declared in block level(scatter across the page). It would be a time taking process to identify and change the locators if required in future.

    So, Choose which one you feel comfortable based on above points.

提交回复
热议问题