Canonical way to define page objects in Protractor

二次信任 提交于 2019-12-01 02:48:50

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!