Search code examples
javaselenium-webdriverqaf

How to identify multiple WebElements with multiple criteria in QAF?


I'm working on a use case where I need to identify one or more WebElement objects in QAF (Qmetry Automation Framework). In Selenium, I can achieve this by using the @FindAll annotation with multiple @FindBy annotations, like this:

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

However, I couldn't find a similar implementation in QAF. Is there a way to achieve the same result in QAF? I would appreciate any guidance or suggestions on how to approach this in QAF. Thank you!


Solution

  • QAF supports FindBy(org.openqa.selenium.support.FindBy), FindBys(org.openqa.selenium.support.FindBys) from selenium support library in addition to it's own FindBy(com.qmetry.qaf.automation.ui.annotations.FindBy) but not FindAll

    It doesn't mean you can not use it with QAF. To use FindAll you will required to add additional one line code as below in your page class constructor.

    import org.openqa.selenium.support.PageFactory
        ...
    
    class MyPage extends WebDriverBaseTestPage<WebDriverTestPage>
    
        ...
    
        public MyPage() {
            PageFactory.initElements(driver, this);
        }
        ...
    }