Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we write separate page-object for pop-up with a selection drop-down?

I am new to Page-Object model automation using selenium and java. I am using the Page Object model and have each page as a single class and the actions in that page as methods. Should we write separate page-object for a simple pop-up which appears when submitting a form. This pop up is used to select service types and based on the selection correct form will be opened next. I have 'page objects' for the pages before and after this pop up. But for this one I just inserted a direct code to select an option and click next button. Should I create a separate page-object class for this pop-up?(as this is not a Page). Pop-up has 3 options and a Next button to proceed.

like image 874
Silverbullet Avatar asked Dec 06 '22 13:12

Silverbullet


1 Answers

Please read this Martin Follower's article - Page Object.

A quotation:

Despite the term "page" object, these objects shouldn't usually be built for each page, but rather for the significant elements on a page

Imagine a page which has over of dozen tabs, panels etc, and each one have a few fields, buttons etc. It would be impractical to create a huge class for such a page, it would certainly have 300-500 or more lines of code. Such a class would be very hard to maintain.

It's better (in my opinion) to create several small classes (page objects), each for a specific section of the page, each one containing only a few elements, each no more than 50-100 lines of code. We call these classes page fragments instead of page objects, but the concept is the same.

But it will vary from person to person and everyone may have a different opinion on this topic.

like image 150
krokodilko Avatar answered Feb 16 '23 01:02

krokodilko