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

node-horseman

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-horseman - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

4

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
##2.4.0 - 2015-10-08
### Added
- .do(). Closes #53.
##2.3.0 - 2015-10-01

@@ -5,0 +9,0 @@ ### Added

@@ -622,2 +622,16 @@ var fs = require("fs");

/*
* Execute a function without breaking the api chain.
* @param fn The function to run. Must call 'done()' when complete.
*/
exports.do = function(fn){
debug('.do()')
return this.ready.then(function(){
return new Promise(function(resolve, reject){
fn(resolve);
});
});
}
//**************************************************//

@@ -624,0 +638,0 @@ // Information

2

package.json
{
"name": "node-horseman",
"version": "2.3.0",
"version": "2.4.0",
"description": "Run PhantomJS from Node",

@@ -5,0 +5,0 @@ "repository": {

@@ -280,2 +280,14 @@ Horseman

####.do(fn)
Run an function without breaking the chain. Works with asynchronous functions. Must call the callback when complete.
```js
horseman.
.open('http://www.google.com')
.do(function(done){
setTimeout(done,1000);
})
.finally(horseman.close);
```
####.evaluate(fn, [arg1, arg2,...])

@@ -282,0 +294,0 @@ Invokes fn on the page with args. On completion it returns a value. Useful for extracting information from the page.

@@ -7,2 +7,3 @@ var Horseman = require('../lib');

var should = require('should');
var parallel = require('mocha.parallel');

@@ -15,16 +16,8 @@ var app, server, serverUrl;

describe(title, function() {
var horseman;
parallel(title, function() {
beforeEach(function() {
horseman = new Horseman({
it('should set the user agent', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
});
afterEach(function() {
horseman.close();
});
it('should set the user agent', function(done) {
horseman

@@ -37,3 +30,4 @@ .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36")

.then(function(result) {
result.should.equal("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36")
result.should.equal("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36");
horseman.close();
})

@@ -47,3 +41,5 @@ .finally(done);

};
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -60,2 +56,3 @@ .headers(headers)

response.headers['X-Horseman-Header'].should.equal('test header');
horseman.close();
})

@@ -66,2 +63,5 @@ .finally(done);

it('should open a page', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -72,2 +72,3 @@ .open(serverUrl)

data.should.equal(serverUrl);
horseman.close();
})

@@ -78,2 +79,5 @@ .finally(done);

it('should have a HTTP status code', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -84,2 +88,3 @@ .open(serverUrl)

data.should.equal(200);
horseman.close()
})

@@ -90,2 +95,5 @@ .finally(done);

it('should click a link', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -97,3 +105,4 @@ .open(serverUrl)

.then(function(data) {
data.should.equal(serverUrl + "next.html")
data.should.equal(serverUrl + "next.html");
horseman.close();
})

@@ -104,2 +113,5 @@ .finally(done);

it('should go backwards and forwards', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -121,3 +133,4 @@ .open(serverUrl)

.then(function(data) {
data.should.equal(serverUrl + "next.html")
data.should.equal(serverUrl + "next.html");
horseman.close();
});

@@ -129,2 +142,5 @@ })

it('should use basic authentication', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -138,2 +154,3 @@ .authentication('my', 'auth')

result.should.be.above(0);
horseman.close();
})

@@ -144,2 +161,5 @@ .finally(done);

it('should set the viewport', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
var size = {

@@ -156,2 +176,3 @@ width: 400,

vp.width.should.equal(size.width);
horseman.close();
})

@@ -162,3 +183,5 @@ .finally(done);

it('should let you scroll', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -176,2 +199,3 @@ .open('http://www.google.com')

coordinates.left.should.equal(40);
horseman.close();
})

@@ -183,3 +207,5 @@ .finally(done);

it('should add a cookie', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
var cookie = {

@@ -198,2 +224,3 @@ name: "test",

result.cookies[cookie.name].should.equal(cookie.value);
horseman.close();
})

@@ -205,2 +232,5 @@ .finally(done);

it('should clear out all cookies', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -213,2 +243,3 @@ .cookies([])

Object.keys(result.cookies).length.should.equal(0);
horseman.close();
})

@@ -219,2 +250,5 @@ .finally(done);

it('should add an array of cookies', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
var cookies = [{

@@ -238,2 +272,3 @@ name: "test",

result.cookies[cookies[1].name].should.equal(cookies[1].value);
horseman.close();
})

@@ -244,2 +279,5 @@ .finally(done);

it('should post to a page', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
var data = 'universe=expanding&answer=42';

@@ -255,2 +293,3 @@

response.form['universe'].should.equal('expanding');
horseman.close();
})

@@ -262,3 +301,5 @@ .finally(done);

it('should return a status from open', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -268,2 +309,3 @@ .open(serverUrl)

status.should.equal('success');
horseman.close();
})

@@ -280,16 +322,8 @@ .finally(done);

describe(title, function() {
var horseman;
beforeEach(function() {
horseman = new Horseman({
parallel(title, function() {
it('should get the title', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
});
afterEach(function() {
horseman.close();
});
it('should get the title', function(done) {
horseman

@@ -300,2 +334,3 @@ .open(serverUrl)

title.should.equal('Testing Page');
horseman.close();
})

@@ -307,2 +342,5 @@ .finally(done);

it('should verify an element exists', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -313,2 +351,3 @@ .open(serverUrl)

exists.should.be.true;
horseman.close();
})

@@ -320,2 +359,5 @@ .finally(done);

it('should verify an element does not exists', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -326,2 +368,3 @@ .open(serverUrl)

exists.should.be.false;
horseman.close();
})

@@ -332,2 +375,5 @@ .finally(done);

it('should count the number of selectors', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -338,2 +384,3 @@ .open(serverUrl)

count.should.be.above(0);
horseman.close();
})

@@ -345,2 +392,5 @@ .finally(done);

it('should get the html of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -351,2 +401,3 @@ .open(serverUrl)

html.indexOf("code").should.be.above(0);
horseman.close();
})

@@ -357,2 +408,5 @@ .finally(done);

it('should get the text of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -363,2 +417,3 @@ .open(serverUrl)

text.trim().should.equal("This is my code.");
horseman.close();
})

@@ -370,2 +425,5 @@ .finally(done);

it('should get the value of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -376,2 +434,3 @@ .open(serverUrl)

value.should.equal("");
horseman.close();
})

@@ -382,2 +441,5 @@ .finally(done);

it('should get an attribute of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -388,2 +450,3 @@ .open(serverUrl)

value.should.equal("next.html");
horseman.close();
})

@@ -395,2 +458,5 @@ .finally(done);

it('should get a css property of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -401,2 +467,3 @@ .open(serverUrl)

value.should.equal("3px");
horseman.close();
})

@@ -407,2 +474,5 @@ .finally(done);

it('should get the width of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -413,2 +483,3 @@ .open(serverUrl)

value.should.be.above(0);
horseman.close();
})

@@ -419,2 +490,5 @@ .finally(done);

it('should get the height of an element', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -425,2 +499,3 @@ .open(serverUrl)

value.should.be.above(0);
horseman.close();
})

@@ -431,2 +506,5 @@ .finally(done);

it('should determine if an element is visible', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -437,2 +515,3 @@ .open(serverUrl)

visible.should.be.true;
horseman.close();
})

@@ -443,2 +522,5 @@ .finally(done);

it('should determine if an element is not-visible', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -449,2 +531,3 @@ .open(serverUrl)

visible.should.be.false;
horseman.close();
})

@@ -455,2 +538,5 @@ .finally(done);

it('should evaluate javascript', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -463,2 +549,3 @@ .open(serverUrl)

result.should.equal("Testing Page");
horseman.close();
})

@@ -469,2 +556,5 @@ .finally(done);

it('should evaluate javascript with optional parameters', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
var str = "yo";

@@ -478,5 +568,26 @@ horseman

result.should.equal(str);
horseman.close();
})
.finally(done);
});
it('should do a function without breaking the chain', function(done){
var doComplete = false;
var horseman = new Horseman({
injectJquery: bool
});
horseman
.do(function(complete){
setTimeout(function(){
doComplete = true;
complete();
},500)
})
.then(function(){
doComplete.should.be.true;
horseman.close();
})
.finally(done);
});
});

@@ -488,14 +599,4 @@ }

describe(title, function() {
beforeEach(function() {
horseman = new Horseman({
injectJquery: bool
});
});
afterEach(function() {
horseman.close();
});
parallel(title, function() {
after(function() {

@@ -520,2 +621,5 @@ if (fs.existsSync("out.png")) {

it('should inject javascript', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -529,2 +633,3 @@ .open(serverUrl)

result.should.equal("isbob");
horseman.close();
})

@@ -536,2 +641,5 @@ .finally(done);

it('should type and click', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -543,2 +651,3 @@ .open(serverUrl)

value.should.equal('github');
horseman.close();
})

@@ -550,2 +659,5 @@ .finally(done);

it('should clear a field', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -558,2 +670,3 @@ .open(serverUrl)

value.should.equal('');
horseman.close();
})

@@ -564,2 +677,5 @@ .finally(done);

it('should select a value', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -571,2 +687,3 @@ .open(serverUrl)

value.should.equal('1');
horseman.close();
})

@@ -577,2 +694,5 @@ .finally(done);

it('should take a screenshot', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -583,2 +703,3 @@ .open(serverUrl)

fs.existsSync("out.png").should.be.true;
horseman.close();
})

@@ -589,2 +710,5 @@ .finally(done);

it('should take a screenshotBase64', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -596,2 +720,3 @@ .open(serverUrl)

type.should.equal('string');
horseman.close();
})

@@ -603,2 +728,5 @@ .finally(done);

it('should let you zoom', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -618,2 +746,3 @@ .open(serverUrl)

bigSize.should.be.greaterThan(smallSize);
horseman.close();
})

@@ -625,2 +754,5 @@ .finally(done);

it('should let you export as a pdf', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -642,2 +774,3 @@ .open('http://www.google.com')

euroSize.should.be.greaterThan(0);
horseman.close();
})

@@ -657,2 +790,5 @@ .finally(done);

it('should verify a file exists before upload', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -663,2 +799,3 @@ .open("http://validator.w3.org/#validate_by_upload")

err.toString().indexOf("Error").should.be.above(-1);
horseman.close();
})

@@ -670,2 +807,5 @@ .finally(done);

it('should fire a keypress when typing', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -686,2 +826,3 @@ .open("http://httpbin.org/forms/post")

keypresses.should.equal(6);
horseman.close();
})

@@ -692,2 +833,5 @@ .finally(done);

it('should send mouse events', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -729,2 +873,3 @@ .open('https://dvcs.w3.org/hg/d4e/raw-file/tip/mouse-event-test.html')

events['mousemove'].should.be.greaterThan(0);
horseman.close();
})

@@ -735,2 +880,5 @@ .finally(done);

it('should send keyboard events', function(done) {
var horseman = new Horseman({
injectJquery: bool
});
horseman

@@ -744,2 +892,3 @@ .open('http://unixpapa.com/js/testkey.html')

data.indexOf("keyCode=13").should.be.greaterThan(-1);
horseman.close();
})

@@ -794,3 +943,3 @@ .finally(done);

describe("Inject jQuery", function() {
parallel("Inject jQuery", function() {
it('should inject jQuery', function(done) {

@@ -852,15 +1001,5 @@ var horseman = new Horseman();

describe("Waiting", function() {
var horseman;
beforeEach(function() {
horseman = new Horseman();
});
afterEach(function() {
horseman.close();
});
parallel("Waiting", function() {
it('should wait for the page to change', function(done) {
var horseman = new Horseman();
horseman

@@ -873,2 +1012,3 @@ .open(serverUrl)

url.should.equal(serverUrl + "next.html");
horseman.close();
})

@@ -882,3 +1022,3 @@ .finally(done);

};
var horseman = new Horseman();
horseman

@@ -890,2 +1030,3 @@ .open('http://www.google.com/')

url.should.equal('http://www.google.com/');
horseman.close();
})

@@ -897,3 +1038,3 @@ .finally(done);

var start = new Date();
var horseman = new Horseman();
horseman

@@ -906,2 +1047,3 @@ .open(serverUrl)

diff.should.be.greaterThan(999); //may be a ms or so off.
horseman.close();
})

@@ -912,2 +1054,3 @@ .finally(done);

it('should wait until a selector is seen', function(done) {
var horseman = new Horseman();
horseman

@@ -919,2 +1062,3 @@ .open(serverUrl)

count.should.be.above(0);
horseman.close();
})

@@ -1002,16 +1146,6 @@ .finally(done);

*/
describe("Frames", function() {
describe("Frames", function() {
var horseman;
beforeEach(function() {
horseman = new Horseman();
});
afterEach(function() {
horseman.close();
});
it('should let you switch to a child frame', function(done) {
var horseman = new Horseman();
horseman

@@ -1023,3 +1157,4 @@ .open(serverUrl + "frames.html")

.then(function(html) {
html.should.equal("This is frame 1.")
html.should.equal("This is frame 1.");
horseman.close();
})

@@ -1035,17 +1170,7 @@ .finally(done);

*/
describe('Events', function() {
parallel('Events', function() {
var horseman;
beforeEach(function() {
horseman = new Horseman();
});
afterEach(function() {
horseman.close();
});
it('should fire an event on initialized', function(done) {
var fired = false;
var horseman = new Horseman();
horseman

@@ -1058,2 +1183,3 @@ .on("initialized", function() {

fired.should.be.true;
horseman.close();
})

@@ -1064,2 +1190,3 @@ .finally(done);

it('should fire an event on load started', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1074,2 +1201,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1080,2 +1208,3 @@ .finally(done);

it('should fire an event on load finished', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1091,2 +1220,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1097,2 +1227,3 @@ .finally(done);

it('should fire an event when a resource is requested', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1107,2 +1238,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1113,2 +1245,3 @@ .finally(done);

it('should fire an event when a resource is received', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1123,2 +1256,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1129,2 +1263,3 @@ .finally(done);

it('should fire an event when navigation requested', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1139,2 +1274,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1145,2 +1281,3 @@ .finally(done);

it('should fire an event when the url changes', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1155,2 +1292,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1161,2 +1299,3 @@ .finally(done);

it('should fire an event when a console message is seen', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1174,2 +1313,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1180,2 +1320,3 @@ .finally(done);

it('should fire an event when an alert is seen', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1193,2 +1334,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1199,2 +1341,3 @@ .finally(done);

it('should fire an event when a prompt is seen', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1212,2 +1355,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1223,14 +1367,6 @@ .finally(done);

describe('Tabs', function() {
var horseman;
parallel('Tabs', function() {
beforeEach(function() {
horseman = new Horseman();
});
afterEach(function() {
horseman.close();
});
it('should let you open a new tab', function(done) {
var horseman = new Horseman();
horseman

@@ -1242,2 +1378,3 @@ .open(serverUrl)

count.should.equal(2);
horseman.close();
})

@@ -1248,2 +1385,3 @@ .finally(done);

it('should fire an event when a tab is created', function(done) {
var horseman = new Horseman();
var fired = false;

@@ -1259,2 +1397,3 @@

fired.should.be.true;
horseman.close();
})

@@ -1266,2 +1405,3 @@ .finally(done);

it('should let switch tabs', function(done) {
var horseman = new Horseman();
horseman

@@ -1273,3 +1413,4 @@ .open(serverUrl)

.then(function(url){
url.should.equal(serverUrl)
url.should.equal(serverUrl);
horseman.close();
})

@@ -1276,0 +1417,0 @@ .finally(done);

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