[Feature] Support ElementLocatorFactory in page initialising
Feature description
When initialising pages via the PageFactory.initElements method, you can provide an element locator factory. As of now, Spectrum implicitly uses the AjaxElementLocatorFactory as part of the auto-waiting behavior. We'd like the user to be able to decide which ElementLocatorFactory to use, such as the DefaultElementLocatorFactory and any other that could be added in future.
Describe why this should be added to Spectrum
Since page initialisation is managed by Spectrum, we need this feature to be added to the framework. We'd like the user to be able to configure it like this:
drivers:
locatorFactory:
default: { }
Where locatorFactory is a whole new node to be added to drivers. The instance created by the snippet above should be an empty object, since the DefaultElementLocatorFactory doesn't take any argument but the driver.
The internal default should be something like the following snippet, to ensure no breaking change is introduced and the auto-waiting works as expected.
drivers:
locatorFactory:
ajax:
timeout: 30
We would like to have these objects (default, ajax, ...) implement a domain interface named LocatorFactory that defines the buildFor method that takes the driver as argument and return the built ElementLocatorFactory. This way, we can encapsulate the logic needed for the specific locator factory in it, and in the SpectrumPage.init() method we can delegate to it like this:
final ElementLocatorFactory locatorFactory = configuration.getDrivers().getLocatorFactory().buildFor(driver);
PageFactory.initElements(new SpectrumFieldDecorator(locatorFactory), this);