Skip to content

Commit a2aeb87

Browse files
committed
Add initial driver-webdriver implementation
0 parents  commit a2aeb87

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Mochify Driver for WebDriver
2+
3+
Installing selenium server on Mac OS:
4+
5+
```bash
6+
brew install selenium-server-standalone
7+
```
8+
9+
Starting the server:
10+
11+
```bash
12+
selenium-server -port 4444
13+
```
14+
15+
WebDriver configuration:
16+
17+
```json
18+
{
19+
"hostname": "localhost",
20+
"path": "/wd/hub",
21+
"port": 4444,
22+
"capabilities": {
23+
"browserName": "safari"
24+
}
25+
}
26+
```

index.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!DOCTYPE html>
2+
<html><body></body></html>

index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const WebDriver = require('webdriver').default;
4+
5+
exports.mochifyDriver = mochifyDriver;
6+
7+
const default_url = `file:${__dirname}/index.html`;
8+
9+
async function mochifyDriver(options = {}) {
10+
const client = await WebDriver.newSession({
11+
logLevel: 'warn',
12+
hostname: 'localhost',
13+
path: '/wd/hub',
14+
port: 4444,
15+
capabilities: {
16+
browserName: 'safari'
17+
}
18+
});
19+
20+
await client.navigateTo(options.url || default_url);
21+
22+
return {
23+
evaluate: (script) => client.executeScript(script, []),
24+
evaluateReturn: (script) => client.executeScript(`return ${script}`, []),
25+
end: () => client.deleteSession()
26+
};
27+
}

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@mochify/driver-webdriver",
3+
"version": "0.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"webdriver": "^7.7.4"
14+
},
15+
"peerDependencies": {
16+
"@mochify/mochify": "*"
17+
}
18+
}

0 commit comments

Comments
 (0)