示例:
公共类myPageObj扩展了PageObject {
public myPageObj (WebDriver driver) {
super(driver);
}
@FindBy(xpath = "//button[@title='Search']")
private WebElementFacade XPATH_SEARCH_BTN;
public void verifyBtn(){
logger.info("search btn xpath - " + XPATH_SEARCH_BTN);
XPATH_SEARCH_BTN.click();
}
} logger.info不打印xpath。我得到: 搜索btn xpath-DefaultElementLocator'通过ID或名称“ XPATH_SEARCH_BTN”'
如果我在verifyBtn()方法中声明它,则可以正常工作。有人可以阐明为什么在类级别声明的元素未被识别吗?