forked from detro/ghostdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
30 lines (27 loc) · 1.16 KB
/
main.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
// Load dependencies
// NOTE: We need to provide PhantomJS with the "require" module ASAP. This is a pretty s**t way to load dependencies
var ghostdriver = ghostdriver || {},
system = require('system'),
server = require('webserver').create(),
router;
phantom.injectJs("utils/parseuri.js");
phantom.injectJs("errors.js");
phantom.injectJs("session.js");
phantom.injectJs("request_handlers/request_handler.js");
phantom.injectJs("request_handlers/status_request_handler.js");
phantom.injectJs("request_handlers/session_manager_request_handler.js");
phantom.injectJs("request_handlers/session_request_handler.js");
phantom.injectJs("request_handlers/webelement_request_handler.js");
phantom.injectJs("request_handlers/router_request_handler.js");
phantom.injectJs("webelementlocator.js");
// Enable "strict mode" for the 'parseUri' library
parseUri.options.strictMode = true;
// HTTP Request Router
router = new ghostdriver.RouterReqHand();
// Start the server
if (server.listen(system.args[1] || 8080, router.handle)) {
console.log('Ghost Driver running on port ' + server.port);
} else {
console.error("ERROR: Could not start Ghost Driver");
phantom.exit();
}