custom locator strategy#4603
Conversation
|
How should it work in the end, can you please provide with examples? |
|
@christian-bromann and I had a conversation about how to approach this. Essentially this is what we came up with. The user will have to register a locator somewhere in their tests like so browser.addLocatorStrategy(name: string, callback: (args: any[]) => HTMLElement))When they want to use this strategy, they can call it as such: browser.custom$(name: string, strategyArgs: any[]) => WDIOElement | WDIOElement[]Any suggestions / concerns let me know. |
Codecov Report
@@ Coverage Diff @@
## master #4603 +/- ##
==========================================
+ Coverage 99.39% 99.39% +<.01%
==========================================
Files 203 207 +4
Lines 5251 5301 +50
Branches 1128 1145 +17
==========================================
+ Hits 5219 5269 +50
Misses 29 29
Partials 3 3
Continue to review full report at Codecov.
|
|
@baruchvlz , I think might be better to create two methods: browser.custom$(name: string, strategyArgs: any[]) => WDIOElement
browser.custom$$(name: string, strategyArgs: any[]) => WDIOElement[]in such case it would be convenient to work with types and be predictable what you expect to get. |
|
@CrispusDH |
|
@CrispusDH Alternatively, we could add an extra flag to the command for selecting multiple elements. useLocatorStrategy<T = any>(name: string, strategyArgument: T, multiple: boolean) => WDIOElement | WDIOElement[]Adding a dynamic type will allow the user to pass multiple arguments to their script if they require extra logic. I think |
In what way is this confusing?
My concern is that it is not aligned with other command names such as
This is not ensured by the user script. If for whatever reason the script fetches multiple elements, multiple elements will be returned. |
|
There is no real difference between |
52aafb7 to
b21d235
Compare
christian-bromann
left a comment
There was a problem hiding this comment.
Some minor code formatting comments, after that we should be good to go.
|
@baruchvlz can you rebase? |
541139b to
7df2677
Compare
7daf503 to
f56c46c
Compare
christian-bromann
left a comment
There was a problem hiding this comment.
Thanks for implementing, even though pinning scripts in not yet part of WebDriver but with this we are far ahead of already allowing it now to some extend.
Proposed changes
Related issue: #4578
Types of changes
Checklist