如何在QAF中使用多个条件识别多个WebElement?

huangapple go评论62阅读模式
英文:

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 = &quot;class1&quot;),
   @FindBy(className = &quot;class2&quot;)
})
private List&lt;WebElement&gt; 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&lt;WebDriverTestPage&gt;

	...

	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&lt;WebDriverTestPage&gt;

	...

	public MyPage() {
		PageFactory.initElements(driver, this);
	}
	...
}

huangapple
  • 本文由 发表于 2023年6月19日 11:50:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503518.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定