I am using the Pages.getPage in order to create the PageObject dynamically at run-time. The getPage method doesn't allow to pass parameters in order to pass these through the PageObject construct when is instantiated inside the Pages class.
The most common use case where I need this change is to pass to the PageObject to SearchContext. So the PageObject will not search in the entire page to locate different element, it will search within the passed SearchContext from the constructor. A concrete example can be the following:
We have a page with multiple HTML Tables.
We have a single Table page object.
We are reusing this Table page object with creating dynamically instances using Pages.getPage method
I need to pass to each created Table instance the SearchContext where is located the table
My workaround is to pass the SearchContext with a setter method after the Table page object is created by Pages.getPage method.
I am using the Pages.getPage in order to create the PageObject dynamically at run-time. The getPage method doesn't allow to pass parameters in order to pass these through the PageObject construct when is instantiated inside the Pages class. The most common use case where I need this change is to pass to the PageObject to SearchContext. So the PageObject will not search in the entire page to locate different element, it will search within the passed SearchContext from the constructor. A concrete example can be the following:
My workaround is to pass the SearchContext with a setter method after the Table page object is created by Pages.getPage method.
componentCreators.put(PageComponentType.TABLE, (pages, webElement, table) -> { Table table = pages.get(Table.class); table.setTableElement(webElement.findElement(By.xpath(".//table[@id=" +table + "]"))); return table; });
I would like to ask to extend this API in order to allow to pass additional parameters to the Pages.getPage method. Any thoughts about this request?