0

嗨,我正在使用 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)

4

3 回答 3

0

使用这个:: 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("活动");

于 2018-04-30T11:58:50.610 回答
0

使用 Page Factory 时不能使用等待方法。下面的代码创建了一个隐式等待,无论您想使用多少秒。我在示例中使用了 15。

初始化页面对象时,请使用 AjaxElementLocatorFactory。

public LoginPage(WebDriver driver) {
       this.driver = driver;
        PageFactory.initElements(new AjaxElementLocatorFactory(driver, 15), this);
}
于 2018-04-30T17:32:48.720 回答
0

ExpectedConditions.elementToBeClickable 接受 By 或 web 元素。您可以使用 1. elementSelectionStateToBe(By locator, boolean selected) 或 2. elementSelectionStateToBe(WebElement element, boolean selected)

检查给定元素是否被选中的期望。

于 2018-04-30T12:56:49.683 回答