Reputation: 3198
I have some HTML that I want to test...
<div class="privacy-text">
<a on-tap="goPrivacyPolicy()" class="disable-user-behavior">Privacy Policy</a> |
<a on-tap="goTerms()" class="disable-user-behavior">Terms of Service</a>
</div>
In jasmine, I'm trying to see that the elements are present and visible.. but all I get are errors that my functions are not correct.. Am I supposed to use JQuery selectors for the element()
calls??
it("should list a terms of service", function() {
expect(element(by.css('.disable-user-behavior')).count()).toEqual(2);
});
Edit :
I have decided that these elements should have an unique ID so that I can pick them up individually.
element(by.id('privacyPolicy1234')).count();
TypeError: undefined is not a function
Upvotes: 1
Views: 6261
Reputation: 3198
my problem was due to trying to use the
.count()` on `element(...)
it only works on
element.all(...).count()
Thanks to the team behind protractor, they added this
it("should list a terms of service, privacy policy ", function() {
var privacyElement = element(By.id("privacyPolicy1234"));
browser.wait(function(){
privacyElement .isPresent();},
10000,"Element NOT found");
expect(privacyElement.getText()).toContain("Privacy Policy");
writeToLog("saw elements");
});
Upvotes: 3