How can I check if an element is require using Protractor in angular2?

守給你的承諾、 提交于 2020-01-15 08:55:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!