2

As I train myself on Selenium, I'm using Page Object Model as my design. My practice site is https://www.beeradvocate.com (I like beer and it's presenting some testing challenges I was looking for).

Once such instance is a page overlay or modal window.

I know in POM each page has it's own Class where the page objects are located and the corresponding methods/actions to be taken upon them. Furthermore, if I click a link that navigates to another page, that would return a new page object in the function such as:

return new HomePage();

When the Login link is clicked it generates an overlay modal window. It seems that Frames aren't treated as their own Page Class. It takes a switchToFrame() action. Would the same apply for this overlay? Perhaps just a getWindowHandles() action to navigate to it?

2 Answers2

1

I would suggest creating a separate class to represent your modal, especially if it's shared by other pages or may be moved out of that page one day.

But if the modal is super-simple and only included on one page and really specific to that page, then it could be represented by a group of functions within that POM. However you'd need to recognise those methods as a "region" or a sub-group in some way, like namespacing the methods, or using decorators, which I always think in OO terms smells like there's a sub-object here which needs dividing out!

Dividing and composing is pretty cheap in Java so there's not much penalty. But having a big page object with tons of "sub components" can get messy. It probably depends on how well sub-structured the site itself is which will guide your decision. Like if the selector for the modal is relatively clean and separate from the host page itself, it's less "owned" by the page.

This similar answer points out that a "POM" is more of a module reprentation than an entire "page" (whatever that means these days!). https://stackoverflow.com/a/47141290/209288

This answer also asks the same question. https://stackoverflow.com/a/49002231/209288

I came looking for a similar answer, and have just made my mind up to decompose my modals, while reading these discussions. (So my answer is based on 15 minutes of thought, not experience!)

scipilot
  • 6,681
  • 1
  • 46
  • 65
0

I'm working on this too, and the main problem is that you need to find a way to login to the website. If you are not logged in, you can get only actually receive the first 25 reviews..

phil
  • 3
  • 2