2014-12-17 32 views
6

Aşağıdaki tabloyu kullanıyorum. Bunun içinde her bir etiketi (th, td etiketleri), o etiketlerdeki metni ve o metnin sayısını test etmek istiyorum. HTML Böyle çalıştıİletki e2e test tablosu üstbilgisi ve <tr>, <td> tags

<table class="table table-striped"> 
    <tbody> 
     <tr> 
     <th><b><a ng-href="" ng-click="predicate='id';reverse=!reverse">Patient Id</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='accountNumber';reverse=!reverse" class="">Account Number</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='title';reverse=!reverse">Title</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='firstName';reverse=!reverse">First Name</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='lastName';reverse=!reverse">Last Name</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='middleName';reverse=!reverse">Middle Name</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='sex';reverse=!reverse">Sex</a></b></th> 
     <th><b><a ng-href="" ng-click="predicate='dob';reverse=!reverse">Dob</a></b></th>   
     </tr> 

     <tr ng-repeat="listItem in filteredListItems | orderBy:predicate:reverse" ng-class="rowClass(listItem)" class="ng-scope"> 
     <td class="ng-binding">10</td> 
     <td class="ng-binding">Tam</td> 
     <td class="ng-binding">Mr.</td> 
     <td class="ng-binding">Tam</td> 
     <td class="ng-binding">Vinh</td> 
     <td class="ng-binding">J.</td> 
     <td class="ng-binding">F</td> 
     <td class="ng-binding"></td> 
     <td><a ng-href="#/detailView/patients/10" href="#/detailView/patients/10">Details</a></td> 
     <td><button ng-click="deleteRecord(10)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span> Delete</button></td> 
     </tr> 

    <tr ng-repeat="listItem in filteredListItems | orderBy:predicate:reverse" ng-class="rowClass(listItem)" class="ng-scope"> 
     <td class="ng-binding">12</td> 
     <td class="ng-binding">Tam12</td> 
     <td class="ng-binding">Mr.</td> 
     <td class="ng-binding">Steve</td> 
     <td class="ng-binding">John</td> 
     <td class="ng-binding">A.</td> 
     <td class="ng-binding">F</td> 
     <td class="ng-binding"></td> 
     <td><a ng-href="#/detailView/patients/12" href="#/detailView/patients/12">Details</a></td> 
     <td><button ng-click="deleteRecord(12)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span> Delete</button></td> 
     </tr> 
    </tbody> 
</table> 

pasajı, ama işe yaramıyor. Yukarıdaki testte, beklenti çalışıyor, ancak ikinci beklenti işe yaramıyor.

Hata:

Message: 
Expected 'Patient Id' to equal 'Account Number'. 

Yine ikinci beklenti içinde o Hasta kimliği 'bekliyor. Nerede yanlış yaptığımı bilmiyorum. Bunun yerine

cevap

4

, element.all() kullanarak tüm başlıkları bulmak ve tek seferde listesini savunmak için map() kullanın:

var headers = element.all(by.css('table.table th a')).map(function(elm) { 
    return elm.getText(); 
}); 

expect(headers).toEqual([ 
    "Patient Id", 
    "Account Number", 
    "Title", 
    "First Name", 
    "Last Name", 
    "Middle Name", 
    "Sex", 
    "Dob" 
]); 
+0

** Sayısı: ** var list = element.all (by.css ('inci a')); \t beklenen (list.count()) toBe (8); – NNR

+0

** Bireysel Başlık: ** var test = element.all (by.css ('th a')) (2); \t bekliyor (test.getText()) toBe ('Başlık'); – NNR