问题
How can I check if an element(input field or drop down list) is require using Protractor in angular 2?
expect(helpers.hasClass(element(by.id('datasourceName')), 'ng-invalid')).toBe(true);
i'm using helper from below: https://www.npmjs.com/package/protractor-helpers
no idea whether it's correct way or not.
回答1:
locate the input and check with the getAttribute
method:
expect(inputElement.getAttribute("required")).toBe("true");
来源:https://stackoverflow.com/questions/41401433/how-can-i-check-if-an-element-is-require-using-protractor-in-angular2