0

我在那里定义 radioButton 。如果我初始化那里的元素,它会起作用但它不适用于@FindBy 注释。我创建了一个构造函数:

public MyRadioButtons(By optionsNamesLocatorTemplate) {
    super(optionsNamesLocatorTemplate);
    //some code
}

当我运行测试时,我有一个错误:

java.lang.AssertionError:字段的 getElementInstance 出错

如何使用 JDI 风格和方法来定义它们?

4

1 回答 1

0

因为您返回的是 MyRadioButtons 对象,而不是 WebElement 对象。试试这个代码:

WebElement radioButton = driver.findElement(optionsNamesLocatorTemplate);
于 2018-07-19T16:12:43.127 回答