我使用htmlelements模式,类似于pagefactory。搜索通过@FindBy的元素。对于某些元素,无法执行操作(单击,sendkeys ...),因为页面上的表单尚未完全加载,并且似乎未对其执行操作,并且驱动程序已在尝试对其执行操作。仅帮助方法Thread.sleep()。但是我想使用“显式等待”。 Timeouts(),htmlelements的成员没有帮助。
例如:

public class ButtonForm extends HtmlElement {

    @FindBy(xpath = "//span[text()='Select']")
    public Button selectButton;

    public void selectButton() {
        selectButton.click();
    }

在当前测试中,长时间运行的行为没有单击操作。
我想实现像这样的韧带:“WebElement + WebDriverWait + ExpectedConditions”

最佳答案

问题可能在这里@FindBy(xpath = "//span[text()='Select']")。当您使用//启动xpath表达式时,硒将忽略元素上下文并从文档根目录查找。因此,也许您的操作(单击,sendkeys)有效,但是对错误的元素。要解决此问题,请使用./启动xpath或使用CSS定位器。

08-03 22:08
查看更多