Skip to content

Commit 15b1ea9

Browse files
committed
Fix non-keyed test for remove
* Fix non-keyed test for remove. result.removedStoredTr checks any count greater than 0. removeStoredTr represents any <tr> node in target 'table.table'. Removing row two <tr>, index 1, means removedStoredTr will be 1 based on target, which results in an invalid error message. Now the <tr> node to be removed is ignored.
1 parent f1ea4bb commit 15b1ea9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

webdriver-ts/src/isKeyed.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ window.nonKeyedDetector_reset = function() {
4343
window.nonKeyedDetector_tradded = [];
4444
window.nonKeyedDetector_trremoved = [];
4545
window.nonKeyedDetector_removedStoredTr = [];
46+
window.trToBeRemoved = null;
4647
}
4748
4849
window.nonKeyedDetector_setUseShadowDom = function(useShadowDom ) {
@@ -71,7 +72,9 @@ window.nonKeyedDetector_instrument = function() {
7172
let trs = [];
7273
nodeList.forEach(n => {
7374
if (n.tagName==='TR') {
74-
trs.push(n);
75+
if (!trToBeRemoved || trToBeRemoved !== n) {
76+
trs.push(n);
77+
}
7578
trs = trs.concat(filterTRInNodeList(n.childNodes));
7679
}
7780
});
@@ -115,6 +118,14 @@ window.nonKeyedDetector_storeTr = function() {
115118
}
116119
window.storedTr = node.querySelector('tr:nth-child(2)');
117120
}
121+
window.markTrAsToBeRemoved = function(indexOfTr) {
122+
trToBeRemoved = document.querySelector('table'); // <table>
123+
124+
if (trToBeRemoved) {
125+
trToBeRemoved = trToBeRemoved.children[0]; // <tbody>
126+
trToBeRemoved = trToBeRemoved.children[indexOfTr]; // <tr> list
127+
}
128+
}
118129
window.nonKeyedDetector_reset();
119130
`;
120131

@@ -292,6 +303,9 @@ async function runBench(frameworkNames: string[]) {
292303
await driver.executeScript("nonKeyedDetector_storeTr()");
293304
let text = await getTextByXPath(driver, `//tbody/tr[2]/td[2]/a`, false);
294305
await driver.executeScript("window.nonKeyedDetector_reset()");
306+
if (!keyedRun) {
307+
await driver.executeScript("window.markTrAsToBeRemoved(999)");
308+
}
295309
await clickElementByXPath(driver, `//tbody/tr[2]/td[3]/a/span[1]`, false);
296310
await testTextNotContained(driver, `//tbody/tr[2]/td[2]/a`, text, config.TIMEOUT, false);
297311
res = await driver.executeScript("return nonKeyedDetector_result()");

0 commit comments

Comments
 (0)