我定义单选按钮there。如果我初始化there的元素,它可以工作,但是它不能与@FindBy注释一起工作。 我创建一个构造函数:
public MyRadioButtons(By optionsNamesLocatorTemplate) {
super(optionsNamesLocatorTemplate);
//some code
}
运行测试时,出现错误:
java.lang.AssertionError:字段的getElementInstance中发生错误
如何使用JDI样式和方法来定义它们?
答案 0 :(得分:0)
因为您将返回MyRadioButtons对象,而不是WebElement对象。 尝试以下代码:
WebElement radioButton = driver.findElement(optionsNamesLocatorTemplate);