Socket
Socket
Sign inDemoInstall

wd

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wd - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

206

lib/main.js

@@ -22,3 +22,3 @@ var http = require("http")

res.on('end', function() {
try{
try{
var obj = JSON.parse(strip(data));

@@ -77,2 +77,5 @@ } catch (e) {

this.emit('command', opt['method'], over.url || '--');
opt['headers'] = { 'Accept': 'application/json' };
if( opt['method'] == 'POST' )
opt['headers']['Content-Type'] = 'application/json';
return opt;

@@ -86,2 +89,13 @@ }

webdriver.prototype.status = function(cb) {
var _this = this;
var opts = {method: "GET"};
var options = _this.getOpts(opts);
options['path'] = '/wd/hub/status';
var req = http.request(options, callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');
req.end();
};

@@ -125,2 +139,4 @@ webdriver.prototype.init = function(desired, cb) {

console.log("located at: \x1b[33mhttp://code.google.com/p/selenium/wiki/JsonWireProtocol#/session\x1b[0m");
if (cb)
cb({ message: "The environment you requested was unavailable." });
return;

@@ -135,2 +151,3 @@ }

});
req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({desiredCapabilities: _this.desiredCapabilities}));

@@ -140,2 +157,40 @@ req.end();

webdriver.prototype.sessionCapabilities = function(cb) {
var _this = this;
var opts = {url: '', method: "GET"};
var options = _this.getOpts(opts);
var req = http.request(options, callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');
req.end();
};
// alternate strategy to get session capabilities
// extract session capabilities from session list
webdriver.prototype.altSessionCapabilities = function(cb) {
var _this = this;
var opts = {method: "GET"};
var options = _this.getOpts(opts);
options['path'] = '/wd/hub/sessions';
// looking for the current session
var filterCb = function(err, sessions) {
var _ref;
if (!(err != null)) {
sessions = sessions.filter(function(session) {
return session.id === _this.sessionID;
});
return cb(null, (_ref = sessions[0]) != null ? _ref.capabilities : void 0);
} else {
return cb(err, sessions);
}
};
var req = http.request(options, callbackWithData(filterCb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');
req.end();
};
webdriver.prototype.defaultElement = function(element, cb) {

@@ -160,2 +215,3 @@ if (typeof element === "undefined" || element == 'body' || element === null) {

req.on('error', function(e) { cb(e); });
req.write("");

@@ -177,2 +233,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write("");

@@ -189,2 +246,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({script:"return "+code, args:[]}));

@@ -201,2 +259,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({script:code, args:[]}));

@@ -213,2 +272,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({script:code, args:[]}));

@@ -226,2 +286,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({"url":url}));

@@ -239,2 +300,3 @@ req.end();

);
req.on('error', function(e) { cb(e); });
req.write('');

@@ -244,3 +306,3 @@ req.end();

webdriver.prototype.setWaitTimeout = function(ms, cb) {
webdriver.prototype.setImplicitWaitTimeout = function(ms, cb) {
var _this = this;

@@ -253,2 +315,3 @@

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({ms: ms}));

@@ -258,3 +321,32 @@ req.end();

// for backward compatibility
webdriver.prototype.setWaitTimeout = webdriver.prototype.setImplicitWaitTimeout
webdriver.prototype.setAsyncScriptTimeout = function(ms, cb) {
var _this = this;
var req = http.request(
_this.getOpts({url:'/timeouts/async_script'}), function(res) {
if (cb){ cb(); }
});
req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({ms: ms}));
req.end();
};
webdriver.prototype.setPageLoadTimeout = function(ms, cb) {
var _this = this;
var req = http.request(
_this.getOpts({url:'/timeouts/timeouts'}), function(res) {
if (cb){ cb(); }
});
req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({type: 'page load', ms: ms}));
req.end();
};
webdriver.prototype.element = function(using, value, cb) {

@@ -285,2 +377,3 @@ var _this = this;

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({

@@ -316,2 +409,3 @@ using : using,

var req = http.request(_this.getOpts(opts), callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');

@@ -335,2 +429,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write('');

@@ -349,2 +444,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({

@@ -367,2 +463,3 @@ element : element,

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({

@@ -384,2 +481,3 @@ element : element,

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({}));

@@ -398,2 +496,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({}));

@@ -412,2 +511,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({

@@ -427,2 +527,3 @@ button: button

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({}));

@@ -444,2 +545,3 @@ req.end();

req.on('error', function(e) { cb(e); });
req.write(JSON.stringify({

@@ -459,2 +561,3 @@ value : keys

);
req.on('error', function(e) { cb(e); });
req.write('');

@@ -468,2 +571,3 @@ req.end();

var req = http.request(_this.getOpts(opts), callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');

@@ -482,2 +586,3 @@ req.end();

var req = http.request(url, callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');

@@ -490,3 +595,3 @@ req.end();

webdriver.prototype.textPresent = function(searchText, cb, element) {
webdriver.prototype.textPresent = function(searchText, element, cb) {
this.text(element, function(err, text) {

@@ -496,3 +601,3 @@ if (err) {

} else {
cb(err, text.indexOf(searchText) >= -1);
cb(err, text.indexOf(searchText) >= 0);
}

@@ -502,6 +607,19 @@ });

webdriver.prototype.dismiss_alert = function(cb) {
webdriver.prototype.acceptAlert = function(cb) {
var _this = this;
var req = http.request(
_this.getOpts({url:'/accept_alert'}), function(res) {
if (cb){ cb(); }
});
req.on('error', function(e) { cb(e); });
req.write('');
req.end();
};
webdriver.prototype.dismissAlert = function(cb) {
var _this = this;
var req = http.request(
_this.getOpts({url:'/dismiss_alert'}), function(res) {

@@ -511,3 +629,4 @@ if (cb){ cb(); }

req.write(JSON.stringify({}));
req.on('error', function(e) { cb(e); });
req.write('');
req.end();

@@ -525,20 +644,16 @@ };

webdriver.prototype.keyToggle = function(element, keys, cb) {
webdriver.prototype.url = function(cb) {
var _this = this;
var req = http.request(
_this.getOpts({url:'/type'}), function(res) {
if (cb){ cb(); }
});
req.write(JSON.stringify({
value : keys
}));
var url = _this.getOpts({url:'/url', method: "GET"});
var req = http.request(url, callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');
req.end();
};
}
webdriver.prototype.url = function(cb) {
webdriver.prototype.allCookies = function(cb) {
var _this = this;
var url = _this.getOpts({url:'/url', method: "GET"});
var url = _this.getOpts({url:'/cookie', method: "GET"});
var req = http.request(url, callbackWithData(cb, 'value'));
req.on('error', function(e) { cb(e); });
req.write('');

@@ -548,5 +663,58 @@ req.end();

/*
cookie like the following:
{name:'fruit', value:'apple'}
optional fields: path, domain, secure, expiry
check the JsonWire doc for details
*/
webdriver.prototype.setCookie = function(cookie, cb) {
// setting secure otherwise selenium server throws
if ((typeof cookie !== "undefined" && cookie !== null) &&
!((typeof cookie !== "undefined" &&
cookie !== null ? cookie.secure : void 0) != null)) {
cookie.secure = false;
}
var _this = this;
var url = _this.getOpts({url: '/cookie', method: 'POST'});
var body = { cookie: cookie };
var req = http.request(url, function() {
if (cb) {
cb();
}
});
req.on('error', function(e) { cb(e); });
req.write(JSON.stringify(body));
req.end();
};
webdriver.prototype.deleteAllCookies = function(cb) {
var _this = this;
var req = http.request(
_this.getOpts(
{url:'/cookie', method:'DELETE'}
), function(res) {
if (cb){ cb(); }
});
req.on('error', function(e) { cb(e); });
req.write("");
req.end();
}
webdriver.prototype.deleteCookie = function(name, cb) {
var _this = this;
var req = http.request(
_this.getOpts(
{url:'/cookie/' + encodeURIComponent(name) , method:'DELETE'}
), function(res) {
if (cb){ cb(); }
});
req.on('error', function(e) { cb(e); });
req.write("");
req.end();
}
exports.remote = function(host, port, username, accessKey) {
return new webdriver(host, port, username, accessKey);
}

2

package.json
{ "name" : "wd"
, "description" : "WebDriver/Selenium 2 node.js client"
, "tags" : ["web", "automation", "browser", "javascript"]
, "version" : "0.0.11"
, "version" : "0.0.12"
, "author" : "Adam Christian <adam.christian@gmail.com>"

@@ -6,0 +6,0 @@ , "repository" :

@@ -18,3 +18,4 @@ # WD.js -- A light weight WebDriver/Se2 client for node.js

- Peter Braden ([peterbraden](https://github.com/peterbraden))
- Seb Vincent ([sebv](https://github.com/sebv))
## License

@@ -91,2 +92,3 @@

- 'keyToggle': Press a keyboard key (takes an element and a key character'
- 'setCookie': Sets a <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object">cookie</a>
</pre>

@@ -93,0 +95,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc