Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
187 views
in Technique[技术] by (71.8m points)

java - difference between @FindAll and @FindBys annotations in webdriver page factory

Please explain the difference between @FindAll and @FindBys annotations in webdriver page factory concept.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We can use these annotations in those cases when we have more than a single criteria to to identify one or more WebElement objects.

@FindBys : When the required WebElement objects need to match all of the given criteria use @FindBys annotation

@FindAll : When required WebElement objects need to match at least one of the given criteria use @FindAll annotation

Usage:

@FindBys( {
   @FindBy(className = "class1")
   @FindBy(className = "class2")
} )
private List<WebElement> elementsWithBoth_class1ANDclass2;

Here List elementsWithBothclass1ANDclass2 will contain any WebElement which satisfies both criteria.

@FindAll({
   @FindBy(className = "class1")
   @FindBy(className = "class2")
})
private List<WebElement> elementsWithEither_class1ORclass2  

Here List elementsWithEither_class1ORclass2 will contain all those WebElement that satisfies any one of the criteria.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...