0

I am using Selenium POM (page object model) with PF (page factory) for various desktop web browser tests.

I just started quest - testing responsive mobile web on real mobile devices.

I already have over 500 tests for desktop web browser (tons of multi level page objects and test classes). Responsive web has a lot of differences to desktop web (but some identificators are same)

Somehow I need to add those new reponsive web tests into my project. I have those alternatives -

  1. create whole new Page objects + new test classes = ton of work
  2. create whole new Page objects + modify actuall test classes
  3. modify actual Page objects(insert responsive mobile
    elements/actions) + new test classes =less work, bad readability

Which one should I choose ? thanks.

1
  • Why do you want to write new test classes? Are functionalities so much different between mobile and desktop? Commented Aug 28, 2019 at 7:52

1 Answer 1

1

I would look how far I can get with the current page objects and their selectors. Hopefully I can reuse most of the selectors. If not, I have to write new ones. These I would locate in the same page object, because the "page" itself does not change, just how it looks. Readability is bad either way, you either have HomePage vs MobileHomePage or searchInput vs mobileSearchInput.

Maybe adding something like private WebElement getSearchInput(){return currentWidth >= mobileBreakpoint ? searchInput : mobileSearchInput;} could streamline the test code? Then you maybe don't have to create new tests at all, depending on if the flow changes on mobile. You could just set the browser width in your @Before and get the width e.g. from an environment variable. Then run the suite with different widths.

If there is a lot of selector or flow change..yeah then you don't really get around writing new tests and maybe page objects. Then maybe treat mobile e2e testing as a new project and test happy path and high risk areas first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.