Page-object model is a pattern that you can apply it to develop efficient automation framework. With the page-model, it is possible to minimize maintenance cost. Basically page-object means that your every page is inherited from a base class which includes basic functionalities for every page. If you have some new functionalities that every page should have, you can simple add it to the base class. Base class is like the following:
The last part is related to asserting your test cases against to the pages you have by using the unit test class of the language you preferred. Actually, there are two opinions for asserting. The first one it should be page code, and the second one is writing the assertion part in different place. Martin Fowler suggests not using assertion inside of page class.
One of the most maintenance required attributes is object locators. You can also solve this problem by inserting objects for each pages to a single object module by separating them with a container like in a class for each pages.
My example is applied to the www.amazon.com. Why I chose Amazon is that it is modern, well-known and it is very suitable for automation because almost every needed objects have a unique id.
If you want to run it, you should type:
If you want to run it just a class, you should type:
You can pull my repo from github and run it. Don't forget to change valid email and password line in users.py.
If you want to run it, you should type:
python <module-name.py>
If you want to run it just a class, you should type:
python <module-name.py> <class-name>
You can pull my repo from github and run it. Don't forget to change valid email and password line in users.py.