我使用Selenium創建了測試框架併爲測試報告設置了ExtentReports。使用頁面對象模型和@FindBy批註字段爲每個頁面創建自己的WebElement存儲。現在我想創建自定義註釋@Name測試報告中WebElements名稱的自定義註釋實現
@Name(description = "google main page")
@FindBy(linkText = "Gmail")
private WebElement gmail;
並且實現它,以便能夠在我的報告中稍後使用每個WebElement的描述。我有我自己的實現click()方法的
public static void click(WebElement element) {
try{
element.click();
TestReport.addLog(LogStatus.INFO, "Element "+NameImpl.getDescription(element)+" clicked");
} catch (NoSuchElementException e) {
TestReport.addLog(LogStatus.ERROR, "Element "+NameImpl.getDescription(element)+" not found");
}
}
我能夠獲得一流的註釋與反思喜歡這裏
Is it possible to read the value of a annotation in java?
所有元素的描述,但不能得到特定元素的描述用於我的點擊方法。
任何想法如何實現?