I believe you need to extend
rather than include
the PageFactory - ie you need:
extend PageObject::PageFactory
Ruby Quicktips explains the difference well:
You can either use include or extend to mix in a module’s functionality into a class. The difference is this:
- include makes the module’s methods available to the instance of a class, while
- extend makes these methods available to the class itself.
In your case, you want the methods available to the module itself, therefore you need to use extend
.