You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update PageFactory methods signature from WebDriver to SearchContext.
Motivation
Allow elements to be passed as an argument to PageFactory#initElements methods and be used as the SearchContext.
My objective here is to solve issues related to shadow doms and elements lookup.
I currently have this changed implemented on my project which has a lot of shadow DOMs on the page, and being able to provide the shadow element to initElements allows me to use PageFactory with the shadow element as the search context, providing WebDriver would never work as the elements are "hidden" inside the shadow DOM.
No further changes would be needed as upstream classes already use SearchContext as type instead of WebDriver
My current concern is about instantiatePage change. Currently Selenium tries to instantiate the page with 2 different constructors (WebDriver arg and parameterless), I am wondering if there should be a third for SearchContext between the two existing ones, and if it would be useful.
The text was updated successfully, but these errors were encountered:
I would recommend to avoid creating a PR before having a chat on the approach, otherwise the PR might get rejected if it does not align with the implementation idea that Java maintainers have (whatever the idea is). Shadow DOM landed in the W3C spec a while ago and we are waiting for browser vendors to support it (also, follow #5869). In the meantime, the bindings maintainers are starting to implement the endpoints for it.
If you'd like to contribute and have a chat, please join us in our Slack/IRC channel, maintainers normally hangout in the #selenium-tlc channel, and probably you can discuss your approach with @shs96c and others.
🚀 Feature Proposal
Update
PageFactory
methods signature fromWebDriver
toSearchContext
.Motivation
Allow elements to be passed as an argument to
PageFactory#initElements
methods and be used as theSearchContext
.My objective here is to solve issues related to shadow doms and elements lookup.
I currently have this changed implemented on my project which has a lot of shadow DOMs on the page, and being able to provide the shadow element to
initElements
allows me to usePageFactory
with the shadow element as the search context, providing WebDriver would never work as the elements are "hidden" inside the shadow DOM.Example
Only 3 methods need to be updated.
Currently:
With changes:
No further changes would be needed as upstream classes already use
SearchContext
as type instead ofWebDriver
My current concern is about
instantiatePage
change. Currently Selenium tries to instantiate the page with 2 different constructors (WebDriver
arg and parameterless), I am wondering if there should be a third forSearchContext
between the two existing ones, and if it would be useful.The text was updated successfully, but these errors were encountered: