New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nightwatch

Package Overview
Dependencies
Maintainers
1
Versions
360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nightwatch - npm Package Compare versions

Comparing version 0.7.9 to 0.7.10

7

lib/api/expect.js

@@ -92,5 +92,5 @@ var util = require('util');

this.using = using;
this.deferred = Q.defer();
this.startTime = null;
this.emitter = null;
this.createPromise();
}

@@ -108,2 +108,7 @@ util.inherits(Element, events.EventEmitter);

Element.prototype.createPromise = function() {
this.deferred = Q.defer();
return this.deferred.promise;
};
Element.prototype.locate = function(emitter) {

@@ -110,0 +115,0 @@ if (emitter) {

23

lib/api/expect/_baseAssertion.js

@@ -106,2 +106,4 @@ /**

this.resultValue = result.value;
this.resultStatus = result.status;
this.resultErrorStatus = result.errorStatus;

@@ -122,8 +124,2 @@ this.processFlags();

if (this.retries === 0) {
this.messageParts.push(' - element was not found');
this.actual = 'not present';
this.expected = 'present';
}
if (this.shouldRetry() && !this.negate) {

@@ -134,2 +130,6 @@ this.scheduleRetry();

this.messageParts.push(' - element was not found');
this.actual = 'not present';
this.expected = 'present';
this.elementNotFound();

@@ -185,2 +185,6 @@ this.done();

BaseAssertion.prototype.shouldRetryLocateElement = function() {
return (!this.elementResult || this.resultStatus === 10 || this.resultErrorStatus === 10);
};
BaseAssertion.prototype.shouldRetry = function() {

@@ -327,7 +331,8 @@ if (!this.waitForMs) {

BaseAssertion.prototype.retryCommand = function() {
if (this.elementResult) {
this.onPromiseResolved();
} else {
if (this.shouldRetryLocateElement()) {
this.promise = this.element.createPromise();
this.promise.then(this.onPromiseResolved.bind(this), this.onPromiseRejected.bind(this));
this.element.locate();
} else {
this.onPromiseResolved();
}

@@ -334,0 +339,0 @@ };

@@ -66,2 +66,3 @@ /**

PresentAssertion.prototype.retryCommand = function() {
this.promise = this.element.createPromise();
this.element.deferred.promise.then(this.onPromiseResolved.bind(this), this.onPromiseRejected.bind(this));

@@ -68,0 +69,0 @@ this.element.locate();

@@ -51,3 +51,4 @@ /**

if (this.passed && this.waitForMs) {
this.messageParts.push(' - condition was met in ' + this.getElapsedTime() + 'ms');
this.elapsedTime = this.getElapsedTime();
this.messageParts.push(' - condition was met in ' + this.elapsedTime + 'ms');
}

@@ -54,0 +55,0 @@ };

@@ -75,4 +75,3 @@ module.exports = new (function() {

if (isElementCommand) {
var firstArg;
var desiredStrategy;
var firstArg, desiredStrategy, callback;
var elementOrSectionName = args.shift();

@@ -93,8 +92,16 @@ var getter = (isChaiAssertion && commandName === 'section') ? getSection : getElement;

args.unshift(firstArg);
if (typeof args[args.length-1] === 'function') {
callback = args.pop();
}
args.push(function() {
parent.client.locateStrategy = prevLocateStrategy;
if (callback) {
callback.apply(parent.client, arguments);
}
});
}
var c = commandFn.apply(parent.client, args);
if (isElementCommand) {
setLocateStrategy(parent.client, prevLocateStrategy);
}
return (isChaiAssertion ? c : parent);

@@ -101,0 +108,0 @@ };

@@ -110,3 +110,4 @@ var path = require('path');

var index = self.testResults.steps.indexOf(key);
if (index === -1) {
if (!module[key]) {
// backwards compatibility

@@ -117,8 +118,11 @@ key = 'tearDown';

if (index === -1) {
if (module[key]) {
hookFn = module[key];
if (index > -1) {
// not running with --testcase
self.testResults.steps.splice(index, 1);
self.module.removeKey(key);
}
} else {
hookFn = function() {};
} else {
hookFn = module[key];
self.testResults.steps.splice(index, 1);
self.module.removeKey(key);
}

@@ -125,0 +129,0 @@

@@ -119,4 +119,4 @@ var path = require('path');

if (opts.filter) {
return fileMatcher.filter.match(filePath, Matchers.filter);
if (opts.filter && !fileMatcher.filter.match(filePath, Matchers.filter)) {
return false;
}

@@ -123,0 +123,0 @@

{
"name": "nightwatch",
"description": "A node.js bindings implementation for selenium 2.0/webdriver",
"version": "0.7.9",
"version": "0.7.10",
"author": {

@@ -6,0 +6,0 @@ "name": "Andrei Rusu",

@@ -13,3 +13,3 @@ # Nightwatch

Nightwatch works with the Selenium standalone server so the first thing you need to do is download the selenium server jar file `selenium-server-standalone-2.x.x.jar` from the Selenium releases page:
**http://selenium-release.storage.googleapis.com/index.html**
**https://selenium-release.storage.googleapis.com/index.html**

@@ -16,0 +16,0 @@ ### Install Nightwatch

@@ -482,3 +482,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -494,2 +494,17 @@ var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class').before(60);

'to have attribute with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().attributeValue('hp vasq');
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class').before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have attribute "class" in 60ms - attribute was present in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
'to have attribute match - throws exception on invalid regex' : function(test) {

@@ -496,0 +511,0 @@ Nocks.elementFound().attributeValue('xx');

@@ -464,3 +464,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -476,2 +476,16 @@ var expect = this.client.api.expect.element('#weblogin').to.have.css('display').before(60);

'to have css property with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().cssProperty('block');
var expect = this.client.api.expect.element('#weblogin').to.have.css('display').before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have css property "display" in 60ms - property was present in '+ expect.assertion.elapsedTime +'ms');
test.done();
})
},
'to have css property match - element not found' : function(test) {

@@ -478,0 +492,0 @@ Nocks.elementNotFound();

@@ -156,3 +156,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -168,2 +168,16 @@ var expect = this.client.api.expect.element('#weblogin').to.be.enabled.before(60);

'to be enabled with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().enabled();
var expect = this.client.api.expect.element('#weblogin').to.be.enabled.before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be enabled in 60ms - condition was met in '+ expect.assertion.elapsedTime +'ms');
test.done();
})
},
tearDown : function(callback) {

@@ -170,0 +184,0 @@ this.client = null;

@@ -42,3 +42,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound().elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -75,2 +75,15 @@ var expect = this.client.api.expect.element('#weblogin').to.be.present.before(60);

'to be present with waitFor [PASSED on retry]' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound();
var expect = this.client.api.expect.element('#weblogin').to.be.present.before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be present in 60ms - element was present in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
'to not be present [FAILED]' : function(test) {

@@ -77,0 +90,0 @@ Nocks.elementFound();

@@ -156,3 +156,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -168,2 +168,16 @@ var expect = this.client.api.expect.element('#weblogin').to.be.selected.before(60);

'to be selected with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().selected();
var expect = this.client.api.expect.element('#weblogin').to.be.selected.before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be selected in 60ms - condition was met in '+ expect.assertion.elapsedTime +'ms');
test.done();
})
},
tearDown : function(callback) {

@@ -170,0 +184,0 @@ this.client = null;

@@ -291,3 +291,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -303,2 +303,16 @@ var expect = this.client.api.expect.element('#weblogin').text.to.match(/vasq$/).before(60);

'text to match with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().text('hp vasq');
var expect = this.client.api.expect.element('#weblogin').text.to.match(/vasq$/).before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> text to match: "/vasq$/" in 60ms - condition was met in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
'text to match - throws exception on invalid regex' : function(test) {

@@ -305,0 +319,0 @@ Nocks.elementFound().text('xx');

@@ -205,3 +205,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -217,2 +217,16 @@ var expect = this.client.api.expect.element('#weblogin').to.be.an('input').before(60);

'to be with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().name('input');
var expect = this.client.api.expect.element('#weblogin').to.be.an('input').before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be an input in 60ms - condition was met in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
tearDown : function(callback) {

@@ -219,0 +233,0 @@ this.client = null;

@@ -319,3 +319,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -331,2 +331,16 @@ var expect = this.client.api.expect.element('#weblogin').to.have.value.equal('hp vasq').before(60);

'to have value equal with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().value('hp vasq');
var expect = this.client.api.expect.element('#weblogin').to.have.value.equal('hp vasq').before(110);
this.client.on('nightwatch:finished', function(results, errors) {
test.equals(expect.assertion.waitForMs, 110);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have value equal to: "hp vasq" in 110ms - condition was met in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
'to have value match - throws exception on invalid regex' : function(test) {

@@ -333,0 +347,0 @@ Nocks.elementFound().value('xx');

@@ -156,3 +156,3 @@ var Nocks = require('../../nocks.js');

Nocks.elementNotFound();
Nocks.elementNotFound().elementNotFound().elementNotFound();

@@ -168,2 +168,16 @@ var expect = this.client.api.expect.element('#weblogin').to.be.visible.before(60);

'to be visible with waitFor - element found on retry' : function(test) {
this.client.api.globals.waitForConditionPollInterval = 50;
Nocks.elementNotFound().elementFound().visible();
var expect = this.client.api.expect.element('#weblogin').to.be.visible.before(60);
this.client.on('nightwatch:finished', function(results, errors) {
test.equal(expect.assertion.waitForMs, 60);
test.equals(expect.assertion.passed, true);
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be visible in 60ms - condition was met in ' + expect.assertion.elapsedTime + 'ms');
test.done();
})
},
tearDown : function(callback) {

@@ -170,0 +184,0 @@ this.client = null;

@@ -501,2 +501,46 @@ var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib';

testRunWithTagsAndFilterEmpty : function(test) {
var testsPath = path.join(process.cwd(), 'sampletests');
this.Runner.run([testsPath], {
seleniumPort : 10195,
silent : true,
output : false,
globals : {
test : test
},
filter : 'syncnames/*',
tag_filter : ['login']
}, {
output_folder : false,
start_session : true
}, function(err, results) {
test.ok(err);
test.equal(results, false);
test.done();
});
},
testRunWithTagsAndFilterNotEmpty : function(test) {
var testsPath = path.join(process.cwd(), 'sampletests');
this.Runner.run([testsPath], {
seleniumPort : 10195,
silent : true,
output : false,
globals : {
test : test
},
filter : 'tags/*',
tag_filter : ['login']
}, {
output_folder : false,
start_session : true
}, function(err, results) {
test.equal(err, null);
test.ok(('demoTagTest' in results.modules.sample.completed), 'demoTagTest was ran');
test.done();
});
},
testRunWithOutput : function(test) {

@@ -609,2 +653,28 @@ var src_folders = [

testRunTestCaseWithBeforeAndAfter : function(test) {
var testsPath = path.join(process.cwd(), '/sampletests/before-after/syncBeforeAndAfter.js');
test.expect(11);
this.Runner.run([testsPath], {
seleniumPort : 10195,
silent : true,
output : false,
globals : {
test : test
}
}, {
output_folder : false,
start_session : true,
testcase : 'demoTestSyncOne'
}, function(err, results) {
test.equals(err, null);
var result = results.modules.syncBeforeAndAfter.completed;
test.ok('demoTestSyncOne' in result);
test.ok(!('beforeEach' in result));
test.ok(!('before' in result));
test.ok(!('afterEach' in result));
test.ok(!('after' in result));
test.done();
});
},
testRunTestcaseInvalid : function(test) {

@@ -611,0 +681,0 @@ var testsPath = path.join(process.cwd(), '/sampletests/before-after/syncBeforeAndAfter.js');

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