Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webdriverjs

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webdriverjs - npm Package Compare versions

Comparing version 0.3.5 to 0.4.0

lib/protocol/frame.js

1

lib/commands/click.js
exports.command = function(cssSelector, callback)
{
var self = this;
self.element("css selector", cssSelector,

@@ -6,0 +5,0 @@ function(result)

exports.command = function(cssSelector, callback)
{
var self = this;
self.element("css selector", cssSelector,

@@ -9,2 +10,3 @@ function(result)

{
self.elementIdText(result.value.ELEMENT,

@@ -15,3 +17,3 @@ function(result)

{
callback(result.value);
callback(result);
}

@@ -18,0 +20,0 @@ }

exports.command = function(cssSelector, callback)
{
var self = this;
self.element("css selector", cssSelector,

@@ -6,0 +6,0 @@ function(result)

var http = require("http");
var commandOptions = {
path: "element",
method: "POST"
};
exports.command = function(using, value, callback)
{
var commandOptions = {
path: "element",
method: "POST"
};
var self = this;
var data;
var check = /class name|css selector|id|name|link text|partial link text|tag name|xpath/gi;

@@ -19,4 +23,4 @@ if (!using.match(check))

this.executeProtocolCommand(
this.createOptions(commandOptions),
this.proxyResponse(callback),
commandOptions,
self.proxyResponse(callback),
data

@@ -23,0 +27,0 @@ );

var http = require("http");
var commandOptions = {
path: "element/:id/click",
method: "POST"
};
exports.command = function(id, callback)
{
var commandOptions = {
path: "element/:id/click",
method: "POST"
};
var requestOptions = this.createOptions(commandOptions);

@@ -11,0 +13,0 @@ requestOptions.path = requestOptions.path.replace(/:id/gi, id);

var http = require("http");
var commandOptions = {
path: "element/:id/css/:propertyName",
method: "GET"
};
exports.command = function(id, cssProperyName, callback)
{
var requestOptions = this.createOptions(commandOptions);
var commandOptions = {
path: "element/:id/css/:propertyName",
method: "GET"
};
var requestOptions = commandOptions;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -12,0 +14,0 @@ requestOptions.path = requestOptions.path.replace(":propertyName", cssProperyName);

var http = require("http");
var commandOptions = {
path: "element/:id/displayed",
method: "GET"
};
exports.command = function(id, callback)
{
var requestOptions = this.createOptions(commandOptions);
var commandOptions = {
path: "element/:id/displayed",
method: "GET"
};
var requestOptions = commandOptions;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);
var request = this.createRequest(requestOptions, this.proxyResponse(callback));
var data = JSON.stringify({});
request.write(data);
request.end();
var data = {};
this.executeProtocolCommand(
requestOptions,
this.proxyResponse(callback),
data
);
};
var http = require("http");
var commandOptions = {
path: "element/:id/size",
method: "GET"
};
exports.command = function(id, callback)
{
var requestOptions = this.createOptions(commandOptions);
var commandOptions = {
path: "element/:id/size",
method: "GET"
};
var requestOptions = commandOptions;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -12,0 +14,0 @@

var http = require("http");
var commandOptions = {
path: "element/:id/text",
method: "GET"
};
exports.command = function(id, callback)
{
var requestOptions = this.createOptions(commandOptions);
var commandOptions = {
path: "element/:id/text",
method: "GET"
};
var requestOptions = commandOptions;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);
var request = this.createRequest(requestOptions, this.proxyResponse(callback));
var data = JSON.stringify({});
request.write(data);
request.end();
var data = {};
this.executeProtocolCommand(
requestOptions,
this.proxyResponse(callback),
data
);
};
var http = require("http");
var commandOptionsPost = {
path: "element/:id/value",
method: "POST"
};
var commandOptionsGet = {
path: "element/:id/value",
method: "GET"
};

@@ -16,3 +8,12 @@ exports.command = function(id, value, callback)

var commandOptionsPost = {
path: "element/:id/value",
method: "POST"
};
var commandOptionsGet = {
path: "element/:id/value",
method: "GET"
};
var self = this;

@@ -23,3 +24,3 @@

{
var requestOptions = this.createOptions(commandOptionsPost);
var requestOptions = commandOptionsPost;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -41,3 +42,3 @@ var data = {"value": value.split("")};

var requestOptions = this.createOptions(commandOptionsPost);
var requestOptions = commandOptionsPost;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -44,0 +45,0 @@

var http = require("http");
var commandOptions = {
path: "elements",
method: "POST"
}
exports.command = function(using, value, callback)
{
var check = /class name|css selector|id|name|link text|partial link text|tag name|xpath/gi
var commandOptions = {
path: "elements",
method: "POST"
};
var check = /class name|css selector|id|name|link text|partial link text|tag name|xpath/gi;
if (!using.match(check))

@@ -15,6 +17,11 @@ {

}
var request = this.createRequest(this.createOptions(commandOptions), this.proxyResponse(callback));
var data = JSON.stringify( {"using": using, "value": value} );
request.write(data);
request.end();
var data = {"using": using, "value": value};
this.executeProtocolCommand(
commandOptions,
this.proxyResponse(callback),
data
);
};
var http = require("http");
var commandOptions = {
path: "execute",
method: "POST"
}
exports.command = function(script, callback)
{
var request = this.createRequest(this.createOptions(commandOptions), this.proxyResponse(callback));
var commandOptions = {
path: "execute",
method: "POST"
}
var request = this.createRequest(commandOptions, this.proxyResponse(callback));
var data = JSON.stringify( {"script": script, args: []} );

@@ -12,0 +14,0 @@ request.write(data);

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

var startOptions = self.createOptions({});
var startOptions = {};

@@ -44,2 +44,4 @@ var request = this.createRequest(startOptions,

//console.log("NEW SESSION")
var locationList = response.headers.location.split("/");

@@ -46,0 +48,0 @@ self.sessionId = locationList[locationList.length - 1];

var http = require("http");
var commandOptions = {
path: "screenshot",
method: "GET"
}
exports.command = function(callback)
{
var request = this.createRequest(this.createOptions(commandOptions), this.proxyResponse(callback));
var commandOptions = {
path: "screenshot",
method: "GET"
}
var request = this.createRequest(commandOptions, this.proxyResponse(callback));
var data = JSON.stringify( {} );

@@ -12,0 +14,0 @@ request.write(data);

var http = require("http");
var commandOptionsGet = {
path: "",
method: "GET"
}
var commandOptionsDelete = {
path: "",
method: "DELETE"
}
exports.command = function(doWhat, callback)
{
var commandOptionsGet = {
path: "",
method: "GET"
}
var commandOptionsDelete = {
path: "",
method: "DELETE"
}
var self = this;

@@ -28,9 +30,7 @@ var options, request;

{
//throw "This method gives an error on the server. Dont know why.";
//return;
request = this.createRequest(this.createOptions(commandOptionsGet), this.proxyResponse(callback));
request = this.createRequest(commandOptionsGet, this.proxyResponse(callback));
}
else if (doWhat.toLowerCase() === "delete")
{
request = this.createRequest(this.createOptions(commandOptionsDelete),
request = this.createRequest(commandOptionsDelete,
function()

@@ -37,0 +37,0 @@ {

var http = require("http");
var commandOptionsGet = {
path: "element/:id/submit",
method: "POST"
};
exports.command = function(id, callback)
{
var commandOptionsGet = {
path: "element/:id/submit",
method: "POST"
};
var self = this;
var request, data, requestOptions;
requestOptions = this.createOptions(commandOptionsGet);
requestOptions = commandOptionsGet;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -15,0 +17,0 @@ request = this.createRequest(requestOptions, this.proxyResponseNoReturn(callback));

@@ -10,6 +10,12 @@ var http = require("http");

{
var commandOptions = {
path: "title",
method: "GET"
}
var data = {};
this.executeProtocolCommand(
this.createOptions(commandOptions),
commandOptions,
this.proxyResponse(callback),

@@ -16,0 +22,0 @@ data

@@ -1,17 +0,18 @@

var http = require("http");
var commandOptionsPost = {
path: "url",
method: "POST"
}
var commandOptionsGet = {
path: "url",
method: "GET"
}
exports.command = function(url, callback)
{
var commandOptionsPost = {
path: "url",
method: "POST"
}
var commandOptionsGet = {
path: "url",
method: "GET"
}
var self = this;
var options, request, data;
var data;

@@ -21,4 +22,9 @@ // set

{
request = this.createRequest(this.createOptions(commandOptionsPost), this.proxyResponseNoReturn(callback));
data = JSON.stringify( {"url": url} );
// request = this.createRequest(this.createOptions(commandOptionsPost), this.proxyResponseNoReturn(callback));
data = {"url": url};
this.executeProtocolCommand(
commandOptionsPost,
self.proxyResponseNoReturn(callback),
data
);
}

@@ -30,10 +36,25 @@

callback = url;
request = this.createRequest(this.createOptions(commandOptionsGet), this.proxyResponse(callback));
data = JSON.stringify({});
//request = this.createRequest(this.createOptions(commandOptionsGet), this.proxyResponse(callback));
data = {};
this.executeProtocolCommand(
commandOptionsGet,
self.proxyResponse(callback),
data
);
}
request.write(data);
/* request.write(data);
request.end();
var data = JSON.stringify({});
this.executeProtocolCommand(
requestOptions,
this.proxyResponse(callback),
data
);
*/
};
var http = require("http");
var commandOptionsPost = {
path: "element/:id/value",
method: "POST"
};
exports.command = function(id, value, callback)
{
var commandOptionsPost = {
path: "element/:id/value",
method: "POST"
};
var commandOptionsGet = {
path: "element/:id/value",
method: "GET"
};
var commandOptionsGet = {
path: "element/:id/value",
method: "GET"
};
exports.command = function(id, value, callback)
{
var self = this;

@@ -21,3 +24,3 @@ var request, data, requestOptions;

{
requestOptions = this.createOptions(commandOptionsPost);
requestOptions = commandOptionsPost;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -32,3 +35,3 @@ request = this.createRequest(requestOptions, this.proxyResponseNoReturn(callback));

callback = value;
requestOptions = this.createOptions(commandOptionsGet);
requestOptions = commandOptionsGet;
requestOptions.path = requestOptions.path.replace(/:id/gi, id);

@@ -35,0 +38,0 @@ request = this.createRequest(requestOptions, this.proxyResponse(callback));

var http = require("http");
var commandOptions = {
path: "window",
method: "POST"
}
exports.command = function(windowHandle, callback)
{
var commandOptions = {
path: "window",
method: "POST"
}
var data = {"name": windowHandle};
this.executeProtocolCommand(
this.createOptions(commandOptions),
commandOptions,
this.proxyResponseNoReturn(callback),

@@ -15,0 +17,0 @@ data

var http = require("http");
var commandOptions = {
path: "window_handles",
method: "GET"
}
exports.command = function(callback)
{
var commandOptions = {
path: "window_handles",
method: "GET"
}
var data = {};
this.executeProtocolCommand(
this.createOptions(commandOptions),
commandOptions,
this.proxyResponse(callback),

@@ -15,0 +17,0 @@ data

@@ -7,2 +7,3 @@ // this is my take on a client for the webdriver

var path = require('path');
var infoHasBeenShown = false;

@@ -51,3 +52,3 @@ // useful colors for bash

{
options = options || {};

@@ -69,3 +70,3 @@ var self = this;

self.queuedPaused = false;
var startPath = '/wd/hub/session';

@@ -82,2 +83,6 @@

// defaultOptions = self.extend(defaultOptions, options);
if (options.silent === true)

@@ -437,3 +442,3 @@ {

if (!self.silent)
if (!self.silent && !infoHasBeenShown)
{

@@ -450,2 +455,4 @@ console.log("");

console.log("");
infoHasBeenShown = true;
}

@@ -456,4 +463,6 @@

{
var newOptions = self.extend(defaultOptions, requestOptions);
var path = startPath;

@@ -592,7 +601,9 @@

{
var fulllRequestOptions = this.createOptions(requestOptions);
if (this.showCommandLog)
{
this.log(colors.violet + "COMMAND\t" + colors.reset + requestOptions.method, requestOptions.path);
this.log(colors.violet + "COMMAND\t" + colors.reset + fulllRequestOptions.method, fulllRequestOptions.path);
}
var request = http.request(requestOptions, callback);
var request = http.request(fulllRequestOptions, callback);
return request;

@@ -617,3 +628,3 @@ };

var result;
try

@@ -625,4 +636,7 @@ {

{
console.log("/n" + colors.red + err + colors.reset + "/n");
console.log(colors.dkgrey + data + colors.reset + "/n");
if (data !== "")
{
console.log("/n" + colors.red + err + colors.reset + "/n");
console.log(colors.dkgrey + data + colors.reset + "/n");
}
result = {value: -1};

@@ -642,8 +656,17 @@

{
var value = result.value.length > 50 ? result.value.substring(0, 49) + "..." : result.value;
self.log(colors.teal + "RESULT\t" + colors.reset, value);
}
else if (result.status === 7)
{
result = {value: -1, status: result.status, orgStatus: result.status, orgStatusMessage: errorCodes[result.status].message};
self.log(colors.teal + "RESULT\t" + colors.reset, errorCodes[result.status].id);
}
else
{
// remove the content of the screenshot temporarily so that cthe consle output isnt flooded
var screenshotContent = result.value.screen;
delete result.value.screen;
if (errorCodes[result.status])

@@ -655,6 +678,8 @@ {

{
self.log(colors.red + "ERROR\t" + colors.reset + "\t", result);
}
// add the screenshot again
result.value.screen = screenshotContent;
if (process.argv.length > 1)

@@ -800,8 +825,20 @@ {

var singletonInstance = null;
// expose the man function
// if we need a singleton, we provide the option here
exports.remote = function(options)//host, port, username, pass)
{
return new WebdriverJs(options);//host, port, username, pass);
if (options.singleton)
{
if (!singletonInstance)
{
singletonInstance = new WebdriverJs(options);
}
return singletonInstance;
}
else
{
return new WebdriverJs(options);//host, port, username, pass);
}
};

@@ -5,3 +5,3 @@ {

"tags": ["web", "test", "selenium", "browser", "javascript"],
"version": "0.3.5",
"version": "0.4.0",
"author": "camilo tapia <camilo.tapia@gmail.com>",

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

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