【发布时间】:2020-11-21 08:39:03
【问题描述】:
下面是我在ag-grid 上运行的量角器测试:
element.all(by.css('div.ag-header-cell'))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Spec. or Material", "Grade/Type", "UNS", "Product Form", "%C", "%Mn", "%Si", "%Cr", "%Ni", "%Mo", "Other"]);
});
// Above, we check the text contained in the header cells
// Then I am re-ordering the header cells by dragging 1 of them over the other:
browser.actions()
.dragAndDrop(
element(by.xpath('/html/body/app-root/app-shell/div/app-chemistry/div/div[2]/div/ag-grid-angular/div/div[1]/div/div[1]/div[2]/div/div/div[5]/div[3]/div/span[1]')),
element(by.xpath('/html/body/app-root/app-shell/div/app-chemistry/div/div[2]/div/ag-grid-angular/div/div[1]/div/div[1]/div[2]/div/div/div[10]/div[3]/div')))
.perform();
// I used `browser.sleep(10000)` to verify the re-ordering is happening.
// Then I added this code with the titles re-ordered:
element.all(by.css('div.ag-header-cell'))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Spec. or Material", "Grade/Type", "UNS", "Product Form", "%Mn", "%Si", "%Cr", "%Ni", "%Mo", "%C", "Other"]);
});
但是,测试失败了,需要原始顺序。
从下面的 HTML 中可以看到,当我将鼠标悬停在 %C 上时,它是页面上的第 10 列,但它仍然是源代码中的第 5 列:
如果 HTML 没有更新,谁能告诉我如何测试这种重新排序?
【问题讨论】:
标签: html angular protractor ag-grid