How to handle AB testing approach with similar page logic but different locators

I have a test suite that currently runs across different development environments. Recently a complete rewrite of the application was done & deployed to a new environment.

The application looks & acts almost identically. Page logic is more or less the same. The big difference is the HTML rewrite has rendered my locators useless. I am unsure how to deal with the locators for this new environment while at the same time adhering to the page object model.

The page object model states that all page logic should be kept in the respective page object class. I am assuming that this includes locators as well.

Following this strategy would leave me with a bloated page object class full of duplicate locators. Is there any recommended best practices or clean solutions to combat this problem ?

The possible solutions i can think of are:

  1. Create separate locator files for each environment and remove them from the page object class.
  2. Create duplicate or similarly named locators in the current page object class
  3. Create separate page objects for the new environment

Can anybody comment on whether or not these solutions sound ok ? Or offer any alternative suggestions ?

2 Likes

Also have a look at

If it was me. I would disambiguate the AB testing problem from the branching problem. The latter problem is very easy to solve, you put all the test code into the same repo as the product code. Job done on that oneโ€ฆ Not always easy, but thatโ€™s how you solve it. AB, is another animal, totally separate problem.

1 Like

Thank you for taking the time to write in such detail. It was enlightening. Many thanks.

I wrote this some time ago that may be useful to you: A/B testing and Selenium automation | autumnator

Your case sounds simple and provided you can use CSS and sometimes XPath for your locators, if it was me, Iโ€™d use the multi-value locator feature of those two locator definition methods. You can then keep locator count the same within page object, but you may have to rework some locators that arenโ€™t already in CSS/XPath, for the ones that are, you simply append/update them with the value for the new flow as well.

1 Like