PageFactory implementation for By/AppiumBy object types

Hello! I recently encountered the following struggle:

I was re-building a cross-platform testing solution and was about to implement changes with PageFactory, as it’s a very efficient way to build tests fast and with less code for 2 platforms at the same time. What happened is that one of the internal SDK’s, used by the project in question, got updated to Java 17 and created a compatibility issue with PageFactory (the problem is that PageFactory uses cglib, which is not maintained nor updated for Java17).

After some thinking I went ahead and implemented a custom and very simplified implementation of a custom PageFactory, which works with By, instead of WebElement. The reasons I did it like that are:

  1. Simplicity - this way the code is quite simplified, without having to instantiate the actual WebElements right away and thus no need for complicated proxying of the objects.
  2. Flexibility - WebElements are great but they are not as flexible as the By locators, and also can be acquired at will as long as you have the By for the given element, but not the other way around.

This ended up being quite effective and I was wondering if this is something that may be of interest/demand? I can contribute my code if moderators agree this could be useful for many many people, I just want to know if this is something that the Appium community may be interested in. It’s purpose will not only be a (more stable) alternative for PageFactory, but also maybe a successor for it, unless the Selenium community updates that part of Selenium to not depend on cglib.

Seems like a good idea, you should check with the folks at:

1 Like

Great, will do. Thanks!

I know, I also saw that they replaced cglib with bytebuddy, which solved the issue. However this implementation, so far from my experience, works very smooth and even faster than the current PageFactory (as it is quite simpler, it doesn’t need to use reflection and proxying at all). I opened an issue in the Java client repo asking if there is interest, but I got no response.