Feature: To support mix of search strategy
amedvedjev opened this issue · 5 comments
Description
@AndroidFindBy(id = "action_bar")
@HowToUseLocators(androidAutomation = ALL_POSSIBLE)
@AndroidFindBy(className = "android.widget.ImageButton")
@AndroidFindBy(className = "android.widget.ImageView")
it does work now for "ImageView" correctly but for "ImageButton" not! For "ImageButton" it get "action_bar" instead.
@amedvedjev It seems it is not the problem of java_client by itself. But it is possible that it is related to
ByAll.
What will happen if you change annotation sequence like
@HowToUseLocators(androidAutomation = ALL_POSSIBLE)
@AndroidFindBy(className = "android.widget.ImageView")
@AndroidFindBy(className = "android.widget.ImageButton")
@AndroidFindBy(id = "action_bar")
It seems that ByAll returns the element tha was found first. By annotation sequence you can regulate the priority of the searching at ALL_POSSIBLE case. I'm not sure that it is needed to define the priority by annotations. However C# clint (Selenium and Appium too) page object attributes (annotations) can regulate it clearly. We could think about this feature further.
what i need is:
- first search by some element -> @AndroidFindBy(id = "action_bar")
- then inside search by any element ->
@AndroidFindBy(className = "android.widget.ImageView")
@AndroidFindBy(className = "android.widget.ImageButton")
e.g.
@AndroidFindBy(id = "action_bar")
@HowToUseLocators(androidAutomation = ALL_POSSIBLE) {
@AndroidFindBy(className = "android.widget.ImageButton")
@AndroidFindBy(className = "android.widget.ImageView")
}
another possibilities are also welcome:
- search by any -> then inside by any again
e.g.
@HowToUseLocators(androidAutomation = ALL_POSSIBLE) {
@AndroidFindBy(id = "action_bar_1")
@AndroidFindBy(id = "action_bar_2")
}
@HowToUseLocators(androidAutomation = ALL_POSSIBLE) {
@AndroidFindBy(className = "android.widget.ImageButton")
@AndroidFindBy(className = "android.widget.ImageView")
}
Ok. I will think about the design. It would be the interesting feature
Thanks Sergey! also don't forget about CHAIN possibility.
The fix was merged at #646. It is going to be available soon.