admin管理员组文章数量:1410682
I am using below table. In that I want to test each tag(th, td tags), Text in that tags and count of that text. HTML snippet
<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>
I tried like this, but it's not working.
it('Patient Page text testing', function(){
var table = element(by.css('.table'));
var firsttag = table.element(by.tagName('tbody'));
var secondtag = firsttag.all(by.tagName('tr')).get(0);
var thirdtag = secondtag.all(by.tagName('th')).get(0);
expect(element(by.xpath('//b/a')).getText()).toEqual('Patient Id');
var thirdtag = secondtag.all(by.tagName('th')).get(1);
expect(element(by.xpath('//b/a')).getText()).toEqual('Account Number');
});
In the above test, expectation is working but second expectation is not working.
Error :
Message:
Expected 'Patient Id' to equal 'Account Number'.
Still in the second expectation it is expecting 'Patient Id'. I don't no where I did wrong.
I am using below table. In that I want to test each tag(th, td tags), Text in that tags and count of that text. HTML snippet
<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>
I tried like this, but it's not working.
it('Patient Page text testing', function(){
var table = element(by.css('.table'));
var firsttag = table.element(by.tagName('tbody'));
var secondtag = firsttag.all(by.tagName('tr')).get(0);
var thirdtag = secondtag.all(by.tagName('th')).get(0);
expect(element(by.xpath('//b/a')).getText()).toEqual('Patient Id');
var thirdtag = secondtag.all(by.tagName('th')).get(1);
expect(element(by.xpath('//b/a')).getText()).toEqual('Account Number');
});
In the above test, expectation is working but second expectation is not working.
Error :
Message:
Expected 'Patient Id' to equal 'Account Number'.
Still in the second expectation it is expecting 'Patient Id'. I don't no where I did wrong.
Share Improve this question edited Dec 17, 2014 at 16:37 alecxe 475k127 gold badges1.1k silver badges1.2k bronze badges asked Dec 17, 2014 at 7:00 Nagarjuna ReddyNagarjuna Reddy 4,19514 gold badges46 silver badges87 bronze badges1 Answer
Reset to default 3Instead, find all headers using element.all()
and use map()
to assert the list in one go:
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"
]);
本文标签: javascriptProtractor e2e test table header and lttrgtlttdgt tagsStack Overflow
版权声明:本文标题:javascript - Protractor e2e test table header and <tr>,<td> tags - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744994920a2636613.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论