@Retention(value=RUNTIME)
@Target(value={FIELD,TYPE})
public @interface FindBys
Used to mark a field on a Page Object to indicate that lookup should use a series of @FindBy tags in a chain as described in ByChained Eg:
@FindBys({@FindBy(id = "foo"),
@FindBy(className = "bar")})
注释类型FindAll
@Retention(value=RUNTIME)
@Target(value={FIELD,TYPE})
public @interface FindAll
Used to mark a field on a Page Object to indicate that lookup should use a series of @FindBy tags It will then search for all elements that match any of the FindBy criteria. Note that elements are not guaranteed to be in document order. Eg:
@FindAll({@FindBy(how = How.ID, using = "foo"),
@FindBy(className = "bar")})
# 1 楼答案
简单地说,@FindBy在@FindBy之间具有和条件关系,而@FindAll具有或条件关系
# 2 楼答案
@FindAll
可以包含多个@FindBy
,并将返回与单个列表中任何@FindBy
匹配的所有元素例如:
鉴于
@FindBys
将根据@FindBy
在其中的指定方式返回元素其中
allElementsInList
包含在id="one"
内具有className="two"
的所有元素# 3 楼答案
当我们有多个标准来标识一个或多个WebElement对象时,我们可以在这些情况下使用这些注释
@FindBys:当所需的WebElement对象需要匹配所有给定条件时,请使用@FindBys注释
@FindAll:需要时,WebElement对象需要至少匹配一个给定条件,请使用@FindAll注释
用法:
这里列出的元素同时包含类别1和类别2将包含满足这两个条件的任何WebElement
这里列出的元素包含所有满足任何一个条件的WebElement
# 4 楼答案
请看JavaDocs:
注释类型FindBys
注释类型FindAll