我想检查输入字段是否包含任何字符串。从下面的代码片段中,我该如何检查?它实际上包含 Assets 管理。
<input _ngcontent-c6="" class="col-md-3 mat-input-element mat-form-field-autofill-control ng-pristine ng-valid ng-touched" id="title" matinput="" placeholder="Object Title" type="text" ng-reflect-model="Asset Management" ng-reflect-id="title" ng-reflect-placeholder="Object Title" ng-reflect-type="text" aria-describedby="mat-hint-2" aria-invalid="false">
最佳答案
设置一种方式来选择你的输入,一个例子:
beforeEach(function() {
input = element(by.id('title'));
});
然后在你的测试中你可以做:
expect(input.getAttribute('value')).toBe('Asset Management')
如果你只是想看看是否有任何值(value):
expect(input.getAttribute('value')).toBeTruthy()
关于angular - 如何检查输入字段是否包含 Protractor 测试中的任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47711507/