2016-07-28 67 views
1

如何要等到元素顯示: 我使用如下:如何等待元素顯示

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) 
+0

是否有任何其他方式來等待元素顯示? – ssharma

回答

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"); 
+0

感謝@Brine幫助。 – ssharma