Skip to content

Commit 5aaeea8

Browse files
committed
#1566 for playwright, webdrivercdp and webdriverAfterframe
1 parent d149b65 commit 5aaeea8

File tree

5 files changed

+64
-666
lines changed

5 files changed

+64
-666
lines changed

webdriver-ts/src/benchmarksPlaywright.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const benchReplaceAll = new (class extends CPUBenchmarkPlaywright {
6868
}
6969
async run(browser: Browser, page: Page) {
7070
await clickElement(page, "#run");
71-
await checkElementContainsText(page, "tbody>tr:nth-of-type(1)>td:nth-of-type(1)", "5001");
71+
await checkElementContainsText(page, "tbody>tr:nth-of-type(1)>td:nth-of-type(1)", `${config.WARMUP_COUNT * 1000 + 1}`);
7272
}
7373
})();
7474

@@ -120,45 +120,50 @@ export const benchSwapRows = new (class extends CPUBenchmarkPlaywright {
120120
await clickElement(page, "#run");
121121
await checkElementExists(page, "tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
122122
for (let i = 0; i <= config.WARMUP_COUNT; i++) {
123-
let text = i % 2 == 0 ? "2" : "999";
123+
let text = i % 2 == 0 ? "2" : "999";
124124
await clickElement(page, "#swaprows");
125125
await checkElementContainsText(page, "tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text);
126126
}
127127
}
128128
async run(browser: Browser, page: Page) {
129129
await clickElement(page, "#swaprows");
130-
await checkElementContainsText(page, "tbody>tr:nth-of-type(999)>td:nth-of-type(1)", "2");
131-
await checkElementContainsText(page, "tbody>tr:nth-of-type(2)>td:nth-of-type(1)", "999");
130+
let text999 = config.WARMUP_COUNT % 2 == 0 ? "999" : "2";
131+
let text2 = config.WARMUP_COUNT % 2 == 0 ? "2" : "999";
132+
await checkElementContainsText(page, "tbody>tr:nth-of-type(999)>td:nth-of-type(1)", text999);
133+
await checkElementContainsText(page, "tbody>tr:nth-of-type(2)>td:nth-of-type(1)", text2);
132134
}
133135
})();
134136

135137
export const benchRemove = new (class extends CPUBenchmarkPlaywright {
136138
constructor() {
137139
super(cpuBenchmarkInfos[Benchmark._06]);
138140
}
141+
rowsToSkip = 4;
139142
async init(browser: Browser, page: Page) {
140143
await checkElementExists(page, "#run");
141144
await clickElement(page, "#run");
142145
await checkElementExists(page, "tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
143146
for (let i = 0; i < config.WARMUP_COUNT; i++) {
144-
await checkElementContainsText(page, `tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(1)`, (config.WARMUP_COUNT - i + 4).toString());
145-
await clickElement(page, `tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
146-
await checkElementContainsText(page, `tbody>tr:nth-of-type(${config.WARMUP_COUNT - i + 4})>td:nth-of-type(1)`, "10");
147+
const rowToClick = config.WARMUP_COUNT - i + this.rowsToSkip;
148+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`, rowToClick.toString());
149+
await clickElement(page, `tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
150+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${rowToClick})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`);
147151
}
148-
await checkElementContainsText(page, `tbody>tr:nth-of-type(5)>td:nth-of-type(1)`, "10");
149-
await checkElementContainsText(page, `tbody>tr:nth-of-type(4)>td:nth-of-type(1)`, "4");
152+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${this.rowsToSkip + 1})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`);
153+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`, `${this.rowsToSkip}`);
150154

151155
// Click on a row the second time
152-
await checkElementContainsText(page, `tbody>tr:nth-of-type(6)>td:nth-of-type(1)`, "11");
153-
await clickElement(page, `tbody>tr:nth-of-type(6)>td:nth-of-type(3)>a>span:nth-of-type(1)`);
154-
await checkElementContainsText(page, `tbody>tr:nth-of-type(6)>td:nth-of-type(1)`, "12");
156+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 2}`);
157+
await clickElement(page, `tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
158+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${this.rowsToSkip + 2})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 3}`);
155159
}
156160
async run(browser: Browser, page: Page) {
157-
await clickElement(page, `tbody>tr:nth-of-type(4)>td:nth-of-type(3)>a>span:nth-of-type(1)`);
158-
await checkElementContainsText(page, `tbody>tr:nth-of-type(4)>td:nth-of-type(1)`, "10");
161+
await clickElement(page, `tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(3)>a>span:nth-of-type(1)`);
162+
await checkElementContainsText(page, `tbody>tr:nth-of-type(${this.rowsToSkip})>td:nth-of-type(1)`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`);
159163
}
160164
})();
161165

166+
162167
export const benchRunBig = new (class extends CPUBenchmarkPlaywright {
163168
constructor() {
164169
super(cpuBenchmarkInfos[Benchmark._07]);

webdriver-ts/src/benchmarksWebdriver.ts

Lines changed: 0 additions & 224 deletions
This file was deleted.

webdriver-ts/src/benchmarksWebdriverAfterframe.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const benchReplaceAll = new (class extends CPUBenchmarkWebdriver {
156156
}
157157
async run(driver: WebDriver) {
158158
await measureClickElementById(driver, "run", true);
159-
await testTextContains(driver, "//tbody/tr[1]/td[1]", "5001", config.TIMEOUT, false);
159+
await testTextContains(driver, "//tbody/tr[1]/td[1]", `${config.WARMUP_COUNT * 1000 + 1}`, config.TIMEOUT, false);
160160
}
161161
})();
162162

@@ -201,50 +201,54 @@ export const benchSwapRows = new (class extends CPUBenchmarkWebdriver {
201201
async init(driver: WebDriver) {
202202
await testElementLocatedById(driver, "run", SHORT_TIMEOUT, true);
203203
await clickElementById(driver, "run", true);
204-
await testElementLocatedByXpath(driver, "//tbody/tr[1]/td[2]/a", config.TIMEOUT, false);
204+
await testElementLocatedByXpath(driver, "//tbody/tr[1]/td[1]", config.TIMEOUT, false);
205205
for (let i = 0; i <= config.WARMUP_COUNT; i++) {
206-
let text = await getTextByXPath(driver, "//tbody/tr[2]/td[2]/a", false);
206+
let text = i % 2 == 0 ? "2" : "999";
207207
await clickElementById(driver, "swaprows", true);
208-
await testTextContains(driver, "//tbody/tr[999]/td[2]/a", text, config.TIMEOUT, false);
208+
await testTextContains(driver, "//tbody/tr[999]/td[1]", text, config.TIMEOUT, false);
209209
}
210210
}
211211
async run(driver: WebDriver) {
212-
let text = await getTextByXPath(driver, "//tbody/tr[2]/td[2]/a", false);
213-
await measureClickElementById(driver, "swaprows", true);
214-
await testTextContains(driver, "//tbody/tr[999]/td[2]/a", text, config.TIMEOUT, false);
212+
await clickElementById(driver, "swaprows", true);
213+
let text999 = config.WARMUP_COUNT % 2 == 0 ? "999" : "2";
214+
let text2 = config.WARMUP_COUNT % 2 == 0 ? "2" : "999";
215+
await testTextContains(driver, "//tbody/tr[999]/td[1]", text999, config.TIMEOUT, false);
216+
await testTextContains(driver, "//tbody/tr[2]/td[1]", text2, config.TIMEOUT, false);
215217
}
216218
})();
217219

218220
export const benchRemove = new (class extends CPUBenchmarkWebdriver {
219221
constructor() {
220222
super(cpuBenchmarkInfos[Benchmark._06]);
221223
}
224+
rowsToSkip = 4;
222225
async init(driver: WebDriver) {
223226
await testElementLocatedById(driver, "run", SHORT_TIMEOUT, true);
224227
await clickElementById(driver, "run", true);
225-
await testElementLocatedByXpath(driver, "//tbody/tr[1]/td[2]/a", config.TIMEOUT, false);
228+
await testElementLocatedByXpath(driver, "//tbody/tr[1000]/td[1]", config.TIMEOUT, false);
226229
for (let i = 0; i < config.WARMUP_COUNT; i++) {
230+
const rowToClick = config.WARMUP_COUNT - i + this.rowsToSkip;
227231
await testTextContains(
228232
driver,
229-
`//tbody/tr[${config.WARMUP_COUNT - i + 4}]/td[1]`,
230-
(config.WARMUP_COUNT - i + 4).toString(),
233+
`//tbody/tr[${rowToClick}]/td[1]`,
234+
rowToClick.toString(),
231235
config.TIMEOUT,
232236
false
233237
);
234-
await clickElementByXPath(driver, `//tbody/tr[${config.WARMUP_COUNT - i + 4}]/td[3]/a/span[1]`, false);
235-
await testTextContains(driver, `//tbody/tr[${config.WARMUP_COUNT - i + 4}]/td[1]`, "10", config.TIMEOUT, false);
238+
await clickElementByXPath(driver, `//tbody/tr[${rowToClick}]/td[3]/a/span[1]`, false);
239+
await testTextContains(driver, `//tbody/tr[${rowToClick}]/td[1]`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`, config.TIMEOUT, false);
236240
}
237-
await testTextContains(driver, "//tbody/tr[5]/td[1]", "10", config.TIMEOUT, false);
238-
await testTextContains(driver, "//tbody/tr[4]/td[1]", "4", config.TIMEOUT, false);
241+
await testTextContains(driver, `//tbody/tr[${this.rowsToSkip + 1}]/td[1]`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`, config.TIMEOUT, false);
242+
await testTextContains(driver, `//tbody/tr[${this.rowsToSkip}]/td[1]`, `${this.rowsToSkip}`, config.TIMEOUT, false);
239243

240244
// Click on a row the second time
241-
await testTextContains(driver, `//tbody/tr[6]/td[1]`, "11", config.TIMEOUT, false);
242-
await clickElementByXPath(driver, `//tbody/tr[6]/td[3]/a/span[1]`, false);
243-
await testTextContains(driver, `//tbody/tr[6]/td[1]`, "12", config.TIMEOUT, false);
245+
await testTextContains(driver, `//tbody/tr[${this.rowsToSkip + 2}]/td[1]`, `${this.rowsToSkip + config.WARMUP_COUNT + 2}`, config.TIMEOUT, false);
246+
await clickElementByXPath(driver, `//tbody/tr[${this.rowsToSkip + 2}]/td[3]/a/span[1]`, false);
247+
await testTextContains(driver, `//tbody/tr[${this.rowsToSkip + 2}]/td[1]`, `${this.rowsToSkip + config.WARMUP_COUNT + 3}`, config.TIMEOUT, false);
244248
}
245249
async run(driver: WebDriver) {
246-
await measureClickElementByXPath(driver, "//tbody/tr[4]/td[3]/a/span[1]", false);
247-
await testTextContains(driver, "//tbody/tr[4]/td[1]", "10", config.TIMEOUT, false);
250+
await clickElementByXPath(driver, `//tbody/tr[${this.rowsToSkip}]/td[3]/a/span[1]`, false);
251+
await testTextContains(driver, `//tbody/tr[${this.rowsToSkip}]/td[1]`, `${this.rowsToSkip + config.WARMUP_COUNT + 1}`, config.TIMEOUT, false);
248252
}
249253
})();
250254

0 commit comments

Comments
 (0)