-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
executable file
·43 lines (32 loc) · 1.03 KB
/
demo.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
41
42
43
#!/usr/bin/env node
///
// Demo of Selenium browser automation with JavaScript
// Please see the file README.md for more information.
//
// ## Tracking
//
// * Package: demo-selenium-javasript
// * Version: 1.1.0
// * Created: 2019-11-02T00:00:00Z
// * Updated: 2021-10-01T13:05:10Z
// * License: GPL-2.0-or-greater or for custom license contact us
// * Contact: Joel Parker Henderson ([email protected])
///
// Initialize Selenium Webdriver, which is the manager
const {By,Key,Builder} = require("selenium-webdriver");
// Initialize chromedriver, which connects to Google Chrome browser app
require("chromedriver");
async function demo(){
// Initialize
let driver = await new Builder().forBrowser("chrome").build();
// Fetch
await driver.get("https://google.com");
// Search
await driver.findElement(By.name("q")).sendKeys("kittens",Key.RETURN);
// Output
var title = await driver.getTitle();
console.log('Title is:',title);
// Done
await driver.quit();
}
demo();