-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
40 lines (31 loc) · 1.65 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { Builder, By, Key, until } = require('selenium-webdriver');
const edge = require('selenium-webdriver/edge');
(async function example() {
let options = new edge.Options();
options.setBinaryPath("C:\\Users\\joselea\\AppData\\Local\\Microsoft\\Edge SxS\\Application\\msedge.exe");
let driver = edge.Driver.createSession(options);
try {
// Navigate to a sample app that creates detached elements
await driver.get('https://captainbrosset.github.io/detached-elements/');
// After navigation, make sure agents are enabled so we can listen to the events
await driver.sendDevToolsCommand('DOM.enable');
await driver.sendDevToolsCommand('DOM.getDocument');
await driver.sendDevToolsCommand('EdgeDOMMemory.enable');
await driver.sleep(1000);
// Interact with webpage to create detached elements
await driver.findElement(By.className('high-traffic')).sendKeys(Key.ENTER);
await driver.sleep(3000);
await driver.findElement(By.className('stop-traffic')).sendKeys(Key.ENTER);
await driver.sleep(1000);
// Optional
let browser_details = await driver.sendAndGetDevToolsCommand('Browser.getVersion', {});
console.log(browser_details);
let {detachedNodesIds} = await driver.sendAndGetDevToolsCommand('EdgeDOMMemory.getDetachedNodesIds', {});
console.log(`Found ${detachedNodesIds.length} detached elements`);
// Optional, ids change each run so the numbers are not very helpful by themselves.
console.log("Node ids: ", detachedNodesIds);
}
finally {
await driver.quit();
}
})();