如何等待元素显示

时间:2016-07-28 21:07:00

标签: protractor

如何等待元素显示: 我正在使用以下内容:

this.IncList = element.all(by.repeater("incident in $ctrl.allIncidents"));

browser.wait(IncList.count() > 0, 10000,"Element not visible timing out"); 

并获得以下错误:

 Failed: fn is not a function[0m
 Stack:
TypeError: fn is not a function
    at C:\Local_E2E\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:720:12
    at goog.async.run.processWorkQueue (C:\Local_E2E\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
    at process._tickCallback (node.js:369:9)
From: Task: <anonymous>
    at goog.async.run.processWorkQueue (C:\Local_E2E\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
    at process._tickCallback (node.js:369:9)
From: Task: Element not visible timing out
    at [object Object].webdriver.WebDriver.wait (C:\Local_E2E\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:716:21)

1 个答案:

答案 0 :(得分:1)

您可以使用ExpectedConditions等待可见性,或使用number of other conditions。这样的事情对你有用:

var EC = protractor.ExpectedConditions;
this.IncList = element.all(by.repeater("incident in $ctrl.allIncidents"));
// visibility of the _one_ of the elements
browser.wait(EC.visibilityOf(this.IncList.first()), 10000,"Element not visible timing out");