Java 活动元素不';无法与想要的WebElement相比
我有一个用Java编写的selenium测试,它测试页面上的活动元素,以与页面上声明的Java 活动元素不';无法与想要的WebElement相比,java,selenium,compare,element,Java,Selenium,Compare,Element,我有一个用Java编写的selenium测试,它测试页面上的活动元素,以与页面上声明的WebElement进行比较。我在互联网上到处寻找答案,但都没有成功。这就是我所拥有的,但是它失败了,因为它没有比较活动元素和我想要的WebElement public class OWBLocatorInquiryPage extends BasePage { @FindBy(id = "orderNo") private WebElement focusOnOrderNumberWE;
WebElement
进行比较。我在互联网上到处寻找答案,但都没有成功。这就是我所拥有的,但是它失败了,因为它没有比较活动元素和我想要的WebElement
public class OWBLocatorInquiryPage extends BasePage {
@FindBy(id = "orderNo")
private WebElement focusOnOrderNumberWE;
private String locatorInquiryPageString = "locatorInquiry.owb";
public OWBLocatorInquiryPage(WebDriver driver) {
super(driver);
}
public boolean isFocusedOnOrderNumber() {
WebElement focusElement = driver.switchTo().activeElement();
return (focusElement == focusOnOrderNumberWE);
}
}
通过环顾四周,我可以看出,==是地址比较。 这里有一些讨论: 我建议你试试
return (focusElement.equals(focusOnOrderNumberWE));
根据这里的讨论: