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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...