Selenium 在没有 @FindBy 注释的页面工厂中查找元素

问题描述

我想在我的 POM 中定义 WebElement,它是默认使用 Page Factory 制作的,但没有 @FindBy 注释。我创建了一个自定义方法,可以让我在项目中更轻松地选择元素,但我不能强制它忽略 @FindBy 注释。

@FindBy(css = "*.nav__handler")
public WebElement sideBarNavigatorHandler;

public WebElement testElement = myCustomMethod("param"); //<= I would like this one to be defined without @FindBy annotation,at this moment PageFactory forces this WebElement to be selected with ID(as it's default) cause of lack of @FindBy annotation.

@FindBy(css = "*.sth")
public WebElement sthElse;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)