1

How can I verify specific text within an unordered list using Protractor? Here is a sample of the code

<ul class="list-unstyled">
<li ng-repeat="field in parsedTemplate.fields" class="ng-scope">
<span col="col-sm-4" class="ng-binding">Invite (Guest)</span>
<span class="col-sm-6 ng-binding">Type (Primary Guest or Companion)
</span></li>
<li ng-repeat="field in parsedTemplate.fields" class="ng-scope">
<span col="col-sm-4" class="ng-binding">Guest</span>
<span class="col-sm-6 ng-binding">Last Name</span></li>
<li ng-repeat="field in parsedTemplate.fields" class="ng-scope">
<span col="col-sm-4" class="ng-binding">Guest</span>

After that, an Excel spreadsheet is generated and that text needs to be verified as well. It will be the same column names as the list items but the contents will change. Is there a way to verify both without creating duplicate tests?

1

At the very least, you can use .getText() and .toContain() jasmine matcher:

var listItems = element.all(by.repeater("field in parsedTemplate.fields")).$$("span");

expect(listItems.getText()).toContain("Guest");

We've also had accomplished a similar task - compared data in a generated Excel report with what was on the screen. For Excel file parsing, we've used xlsx node module. There were also some technicalities like cleaning up the download folder, waiting for a file to be completely downloaded etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.