首页 > 解决方案 > 如何等待值处于可选择状态

问题描述

嗨,我正在使用 Page Factory 将我的所有定位器保存在一个类中。

@FindBy(xpath="//select[@ng-model='selectedLeadSource']")
    WebElement source_of_lead;
    public Select getSourceOptions() {
        return new Select(source_of_lead);
    }

但我不能使用等待,因为它给我一个错误。

wait.until(ExpectedConditions.elementToBeClickable(onPage.getSourceOptions().selectByValue("Campaign")));

错误 :

ExpectedConditions 类型中的方法 elementToBeClickable(By) 不适用于参数(void)

标签: seleniumpage-factory

解决方案


使用这个:: WebDriverWait wait = new WebDriverWait(driver, 100);

@FindBy(xpath="//select[@ng-model='selectedLeadSource']")

WebElement source_of_lead; element=wait.until(ExpectedConditions.presenceOfElementLocated(source_of_lead));

选择下拉=新选择(元素);dropdown.selectByValue("活动");


推荐阅读