Closed dmakhno closed 11 years ago
Hi, Dmytro! It's very nice to see the first issue here.
We have overriden org.openqa.selenium.support.pagefactory.DefaultElementLocator not for adding findElements() method (it is already present in the original class). The reason is that we need to handle code>@Block</code annotation which is used to specify a way of locating a block of elements and which is a class-targeted annotation. So we need to extend default mechanism of annotation handling and to use extended mechanism in DefaultElementLocator. But there are two major problems:
So we've done the following:
And yes, this patch is to be suggested to Selenium developers. But nevertheless, the current solution is not perfect. We are going to improve it by doing the following:
@FindBy
and @FindBys
annotations, not only fields (reference to the issue).And after we improve our patch we will suggest it to Selenium developers.
And now about using other locators: yes, it would be nice to have such possibility, thank you for the proposal. But we think that it would be better to implement it by simply allowing to pass a locator to initialization methods of HtmlElementLoader class instead of adding new annotations. There are the following reasons:
What is your opinion?
I've also created separate related issues about implementation of this proposal: Make it possible to pass element locator to the initialization methods, Use AjaxElementLocator by default instead of DefaultElementLocator.
issues #4 and #3 are closed. do we need to do something else?
After some code studying, please look into ways to make following improvements
org.openqa.selenium.support.pagefactory.DefaultElementLocator was overriden by ru.yandex.qatools.htmlelements.pagefactory.DefaultElementLocator by adding findElements method.
Making assumption it was made for List, however according to: http://code.google.com/searchframe#2tHw6m3DZzo/trunk/java/client/test/org/openqa/selenium/support/pagefactory/AnnotationsTest.java&q=FindAllBy%20package:selenium%5C.googlecode%5C.com&ct=rc&cd=1&sq= It should work in base, and should be reused.
Note: not clear enough "We need to use a little bit different way of annotations handling while keeping implemented in"
If this change was so important maybe it should be implemented in selenium base.
Full reuse would be nice, because it will allow to reuse seleinum locators such as mentioned DefaultElementLocator, AjaxElementLocator or any other.
The end result can look like
@DefaultElementLocator can be ommited, as default. @AjaxDefaultElementLocator(120) will introduce AjaxElementLocator with timeOutInSeconds = 120 or even @CustomElementLocator( < Factory >, < factoryParams >*)
P.S. I'm first in issue list