英文:
How to identify multiple WebElements with multiple criteria in QAF?
问题
在QAF(Qmetry自动化框架)中,我正在处理一个使用案例,需要识别一个或多个WebElement对象。在Selenium中,我可以使用@FindAll注解和多个@FindBy注解来实现这一点,就像这样:
@FindAll({
@FindBy(className = "class1"),
@FindBy(className = "class2")
})
private List<WebElement> elementsWithEitherClass1OrClass2;
然而,在QAF中,我找不到类似的实现方式。在QAF中是否有一种方法可以实现相同的结果?我将感激在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!
答案1
得分: 0
QAF支持selenium support library
中的FindBy
(org.openqa.selenium.support.FindBy)和FindBys
(org.openqa.selenium.support.FindBys),除了它自己的FindBy
(com.qmetry.qaf.automation.ui.annotations.FindBy),但不支持FindAll
。
这并不意味着你不能在QAF中使用它。要使用FindAll
,你需要在你的页面类构造函数中添加以下一行代码:
import org.openqa.selenium.support.PageFactory
...
class MyPage extends WebDriverBaseTestPage<WebDriverTestPage>
...
public MyPage() {
PageFactory.initElements(driver, this);
}
...
}
英文:
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);
}
...
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论