2015-07-01 33 views
0

我正在使用某種表的角度過濾器,我需要驗證過濾器的結果是否正確。量角器 - 驗證該元素是否存在

我已經與這個表之前,在我點擊元素上工作:

element.all(by.xpath('.//td[.="89" and @class="ultranarrow ng-binding"]')).click(); 

這basicly點擊元素在哪裏<td>有值89.我需要驗證,這個數字還在那裏後,我需要進入例如8號過濾所以我寫這篇文章:

expect(element.all(by.xpath('.//td[.="89" and @class="ultranarrow ng-binding"]')).isPresent()).toBe(true); 

不幸的是我得到一個錯誤:

Object [object Object] has no method 'isPresent'

我沒有找到任何其他方法如何驗證是否存在某些問題,在語法中是否存在某些問題或者是否有任何其他方法可以替代isPresent?

回答

4

isPresent僅適用於ElementFinder,而不是ElementArrayFinder,所以你不應該叫什麼你後過使用all

expect(element(by.xpath('.//td[.="89" and @class="ultranarrow ng-binding"]')).isPresent()).toBe(true); 

如果您確實想使用all,嘗試用count()來代替:

expect(element.all(by.xpath('.//td[.="89" and @class="ultranarrow ng-binding"]')).count()).toBe(1); 
+0

使用它謝謝: )我期望會有問題,但你的消除幫助我理解這個問題:) – Andurit

1

我不確定,但我認爲你不能有element.all(by.xpath(''));
所以你可以嘗試::::

expect(element(by.xpath('.//td[.="89" and @class="ultranarrow ng-binding"]')).isPresent()).toBe(true); 

,或者選擇不同的定位

expect(element.all(by.css('td[class="ultranarrow ng-binding"]')).isPresent()).toBe(true); 
+0

嗨@Sohel Saiyed,我能因爲我用它點擊該元素別的地方上,我只是不知道如果我能與isPresent – Andurit

相關問題