Canonical way to define page objects in Protractor

前端 未结 2 1590
我在风中等你
我在风中等你 2021-01-11 11:38

We\'ve been using the Page Object pattern for quite a while. It definitely helps to organize the end-to-end tests and makes tests more readable and clean.

As Using P

相关标签:
2条回答
  • 2021-01-11 11:56

    Ultimately, I think it is a question of personal preference.

    Yes, you can use the constructor pattern and instantiate a singleton in each test suite... yes you could use a simple object literal as above... yes you could use a factory function...

    Structuring code using inheritance via "classes" (whether pseudo- or ES2015 syntax) vs objects extended via mixins is a much wider debate within application development in general, never mind e2e tests!

    The main thing is clear, consistent practice across your test suites and promoting code reusability wherever possible.

    0 讨论(0)
  • 2021-01-11 12:01

    Alecxe, I had this same question. The answer for me came down to the ability to extend constructor-based page objects. For things I don't need to extend (with a basePage, for example), I use an object literal.

    This is just based on the things I've read and tried... I'd be happy to learn about a better/different pattern.

    I look forward to reading the style guide, Andres.

    0 讨论(0)
提交回复
热议问题