我是量角器的新手并写了一篇简短的期望,希望通过他们的名字获取网格中的所有列:
it('All headers are present', function(){
element.all(by.css('.ag-header-cell-text'))
.map(function(header){
return header.getText()
}).then(function(headers){
expect(headers).toEqual(['Publisher Name', 'IpAddress', 'AddedDate', 'Delete Ip']);
});
});
但是,当我运行测试时,我收到错误,说它无法识别'删除Ip'名称,并且期望值为$ [3]
× All headers are present
- Expected $[3] = '' to equal 'Delete Ip'.
代码(由开发人员而非我自己 - 我正在为他们的代码编写测试)如下:
{headerName: "Publisher Name", field: "abbreviation", width: 298, suppressFilter: true},
{headerName: "IpAddress", field: "ipAddress", width: 298, suppressFilter: true},
{headerName: "AddedDate", field: "addedDate", width: 298, suppressFilter: true},
{headerName: "Delete Ip", field: "value", cellRendererFramework: RemoveIpComponent, colId: "params", width: 180, suppressFilter: true, suppressSorting: true}
请注意,无论何时输入以下内容都会有效(只要删除Ip不存在,我就将其更改为'' - 它的期望:
it('All headers are present', function(){
element.all(by.css('.ag-header-cell-text'))
.map(function(header){
return header.getText()
}).then(function(headers){
expect(headers).toEqual(['Publisher Name', 'IpAddress', 'AddedDate', '']);
});
});
看看删除IP的标题在代码中是如何不同的(作为其字段的值)有什么方法可以通过更改我的测试中的语法而不是''来访问它? HTML如下
<div class="ag-header-row" role="presentation" style="top: 0px; height: 56px; width: 1074px;">
<div class="ag-header-cell ag-header-cell-sortable" role="presentation" col-id="addedDate" style="width: 298px; left: 596px;">
<span class="ag-header-select-all ag-hidden" role="presentation" ref="cbSelectAll">
<span class="ag-checkbox-checked ag-hidden" role="presentation">
<span class="ag-icon ag-icon-checkbox-checked"></span>
</span>
<span class="ag-checkbox-unchecked" role="presentation">
<span class="ag-icon ag-icon-checkbox-unchecked"></span>
</span>
<span class="ag-checkbox-indeterminate ag-hidden" role="presentation">
<span class="ag-icon ag-icon-checkbox-indeterminate"></span>
</span>
<span class="ag-checkbox-label" role="presentation"></span>
</span>
<div class="ag-cell-label-container ag-header-cell-sorted-asc" role="presentation">
<div ref="eLabel" class="ag-header-cell-label" role="presentation">
<span ref="eText" class="ag-header-cell-text" role="columnheader">AddedDate</span>
<span ref="eFilter" class="ag-header-icon ag-filter-icon ag-hidden" aria-hidden="true">
<span class="ag-icon ag-icon-filter"></span>
</span>
<span ref="eSortOrder" class="ag-header-icon ag-sort-order ag-hidden" aria-hidden="true">1</span>
<span ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon" aria-hidden="true">
<span class="ag-icon ag-icon-asc"></span>
</span>
<span ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon ag-hidden" aria-hidden="true">
<span class="ag-icon ag-icon-desc"></span>
</span>
<span ref="eSortNone" class="ag-header-icon ag-sort-none-icon ag-hidden" aria-hidden="true">
<span class="ag-icon ag-icon-none"></span>
</span>
</div>
</div>
</div>
<div class="ag-header-cell" role="presentation" col-id="params" style="width: 180px; left: 894px;">
<span class="ag-header-select-all ag-hidden" role="presentation" ref="cbSelectAll">
<span class="ag-checkbox-checked ag-hidden" role="presentation">
<span class="ag-icon ag-icon-checkbox-checked"></span>
</span>
<span class="ag-checkbox-unchecked" role="presentation">
<span class="ag-icon ag-icon-checkbox-unchecked"></span>
</span>
<span class="ag-checkbox-indeterminate ag-hidden" role="presentation">
<span class="ag-icon ag-icon-checkbox-indeterminate"></span>
</span>
<span class="ag-checkbox-label" role="presentation"></span>
</span>
<div class="ag-cell-label-container" role="presentation">
<div ref="eLabel" class="ag-header-cell-label" role="presentation">
<span ref="eText" class="ag-header-cell-text" role="columnheader">Delete Ip</span>
<span ref="eFilter" class="ag-header-icon ag-filter-icon ag-hidden" aria-hidden="true">
<span class="ag-icon ag-icon-filter"></span>
</span>
</div>
</div>
</div>
</div>
感谢所有帮助!
谢谢!
科斯蒂