【问题标题】:How can I refactoring button webElement with java selenium?如何使用 java selenium 重构按钮 webElement?
【发布时间】:2018-12-03 21:32:47
【问题描述】:

我尝试使用注解 (@FindBy) 来反射 WebElement 按钮。在不同的PageOject 中是相同的 id。我该如何考虑这个 WebElement ? (例如验证、搜索按钮、姓名、生日输入)

【问题讨论】:

标签: java selenium refactoring


【解决方案1】:

您可以使用@FindBy 注释并将网络元素设为私有,并声明访问该私有网络元素的方法。

@FindBy(how=How.XPATH,using="your x path of element")
private WebElement elementName;

public WebElement elementName(){
     return elementName
    }

【讨论】:

  • 如何在不同的 PageObject 中使用这个元素?
  • 创建定义 web 元素的类的实例并调用其公共方法。
  • 我需要在参数中实例化一个带有 WebDriver 的按钮类。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-01
  • 2019-02-04
  • 1970-01-01
  • 2012-08-23
  • 1970-01-01
相关资源
最近更新 更多