Socket
Socket
Sign inDemoInstall

casperjs

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casperjs - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

tests/site/plaintext.notype

1

bin/usage.txt
Usage: casperjs [options] script.[js|coffee] [script argument [script argument ...]]
casperjs [options] test [test path [test path ...]]
casperjs [options] selftest
casperjs [options] __selfcommandtest

@@ -6,0 +5,0 @@ Options:

@@ -70,3 +70,3 @@ # Contribution Guide

CasperJS being partly a testing framework, how irrelevant would be to send a pull request with no test? So, please take the time to write and attach tests to your PR. Furthermore, testing with CasperJS is quite [exhaustively documented](http://casperjs.org/testing.html).
CasperJS being partly a testing framework, how irrelevant would be to send a pull request with no test? So, please take the time to write and attach tests to your PR. Furthermore, testing with CasperJS is quite [exhaustively documented](http://docs.casperjs.org/en/latest/testing.html).

@@ -73,0 +73,0 @@ ### Run tests!

@@ -247,7 +247,8 @@ /*!

* @param Object vals Field values
* @param Function findType Element finder type (css, names, xpath)
* @return Object An object containing setting result for each field,
* including file uploads
* @param String findType Element finder type (css, names, xpath, labels)
* @return Object An object containing setting result for each field, including file uploads
*/
this.fill = function fill(form, vals, findType) {
findType = findType || "names";
/*eslint complexity:0*/

@@ -277,21 +278,2 @@ var out = {

var finders = {
css: function(inputSelector) {
return this.findAll(inputSelector, form);
},
labels: function(labelText) {
var label = this.findOne({type: "xpath", path: '//label[text()="' +
labelText + '"]'}, form);
if (label && label.htmlFor) {
return this.findAll('#' + label.htmlFor, form);
}
},
names: function(elementName) {
return this.findAll('[name="' + elementName + '"]', form);
},
xpath: function(xpath) {
return this.findAll({type: "xpath", path: xpath}, form);
}
};
for (var fieldSelector in vals) {

@@ -301,28 +283,18 @@ if (!vals.hasOwnProperty(fieldSelector)) {

}
var field = finders[findType || "names"].call(this, fieldSelector, form),
value = vals[fieldSelector];
if (!field || field.length === 0) {
out.errors.push('no field matching ' + findType + ' selector "' +
fieldSelector + '" in form');
continue;
}
try {
out.fields[fieldSelector] = this.setField(field, value);
out.fields[fieldSelector] = this.setFieldValue(this.makeSelector(fieldSelector, findType), vals[fieldSelector], form);
} catch (err) {
if (err.name === "FileUploadError") {
var selector;
if (findType === "labels") {
selector = '#' + field[0].id;
} else {
selector = fieldSelector;
}
out.files.push({
type: findType,
selector: selector,
path: err.path
});
} else if (err.name === "FieldNotFound") {
out.errors.push('Unable to find field element in form: ' + err.toString());
} else {
out.errors.push(err.toString());
switch (err.name) {
case "FieldNotFound":
out.errors.push('Unable to find field element in form: ' + err.toString());
break;
case "FileUploadError":
out.files.push({
type: findType,
selector: findType === "labels" ? '#' + err.id : fieldSelector,
path: err.path
});
break;
default:
out.errors.push(err.toString());
}

@@ -337,3 +309,3 @@ }

*
* @param String selector CSS3 selector
* @param String | Object selector CSS3 selector (String only) or XPath object
* @param HTMLElement|null scope Element to search child elements within

@@ -343,3 +315,3 @@ * @return Array|undefined

this.findAll = function findAll(selector, scope) {
scope = scope || this.options.scope;
scope = scope instanceof HTMLElement ? scope : scope && this.findOne(scope) || this.options.scope;
try {

@@ -360,3 +332,3 @@ var pSelector = this.processSelector(selector);

*
* @param String selector CSS3 selector
* @param String | Object selector CSS3 selector (String only) or XPath object
* @param HTMLElement|null scope Element to search child elements within

@@ -366,3 +338,3 @@ * @return HTMLElement|undefined

this.findOne = function findOne(selector, scope) {
scope = scope || this.options.scope;
scope = scope instanceof HTMLElement ? scope : scope && this.findOne(scope) || this.options.scope;
try {

@@ -604,3 +576,3 @@ var pSelector = this.processSelector(selector);

/**
* Retrieves the value of a form field.
* Retrieves the value of an element
*

@@ -611,67 +583,69 @@ * @param String inputName The for input name attr value

*/
this.getFieldValue = function getFieldValue(inputName, _options) {
_options = _options || {};
var getSingleValue = function getSingleValue(input) {
var type;
try {
type = input.getAttribute('type').toLowerCase();
} catch (e) {
type = 'other';
}
this.getFieldValue = function getFieldValue(selector, scope) {
var self = this;
var fields = this.findAll(selector, scope);
var type;
if (input.type === 'select-multiple') {
return [].filter.call(input.options, function(option) {
return !!option.selected;
}).map(function(option) {
return option.value;
});
}
// for Backward Compatibility
if (!(fields instanceof NodeList || fields instanceof Array)) {
this.log("attempting to fetch field element from selector: '" + selector + "'", "info");
fields = this.findAll('[name="' + selector + '"]');
}
if (['checkbox', 'radio'].indexOf(type) === -1) {
return input.value;
}
// single checkbox or… radio button (weird, I know)
if (input.hasAttribute('value')) {
return input.checked ? input.getAttribute('value') : undefined;
}
return input.checked;
};
var getMultipleValues = function getMultipleValues(inputs) {
var type;
type = inputs[0].getAttribute('type').toLowerCase();
if (type === 'radio') {
var value;
[].forEach.call(inputs, function(radio) {
value = radio.checked ? radio.value : value;
});
return value;
} else if (type === 'checkbox') {
var values = [];
[].forEach.call(inputs, function(checkbox) {
if (checkbox.checked) {
values.push(checkbox.value);
}
});
return values;
}
};
var formSelector = '';
if (_options.formSelector) {
formSelector = _options.formSelector + ' ';
if (fields && fields.length > 1) {
type = fields[0].hasAttribute('type') ? fields[0].getAttribute('type') : "other";
fields = [].filter.call(fields, function(elm){
if (elm.nodeName.toLowerCase() === 'input' &&
['checkbox', 'radio'].indexOf(elm.getAttribute('type')) !== -1) {
return elm.checked;
}
return true;
});
}
var inputs = this.findAll(formSelector + '[name="' + inputName + '"]');
if (_options.inputSelector) {
inputs = inputs.concat(this.findAll(_options.inputSelector));
if (fields.length === 0 ) {
return type !== "radio" ? [] : undefined;
}
if (_options.inputXPath) {
inputs = inputs.concat(this.getElementsByXPath(_options.inputXPath));
if (fields.length > 1 ) {
return [].map.call(fields, function(elm) {
var ret = self.getField(elm);
return ret && type === 'checkbox' ? elm.value : ret;
});
}
switch (inputs.length) {
case 0: return undefined;
case 1: return getSingleValue(inputs[0]);
default: return getMultipleValues(inputs);
return this.getField(fields[0]);
};
/**
* Retrieves the value of a form field.
*
* @param HTMLElement An html element
* @return Mixed
*/
this.getField = function getField(field) {
var nodeName, type;
if (!(field instanceof HTMLElement)) {
var error = new Error('getFieldValue: Invalid field ; only HTMLElement is supported');
error.name = 'FieldNotFound';
throw error;
}
nodeName = field.nodeName.toLowerCase();
type = field.hasAttribute('type') ? field.getAttribute('type').toLowerCase() : 'text';
if (nodeName === "select" && field.multiple) {
return [].filter.call(field.options, function(option){
return !!option.selected;
}).map(function(option){
return option.value || option.text;
});
}
if (type === 'radio') {
return field.checked ? field.value : null;
}
if (type === 'checkbox') {
return field.checked;
}
return field.value || '';
};

@@ -682,14 +656,35 @@

*
* @param String selector A DOM CSS3/XPath selector
* @param HTMLElement|String form A form element, or a CSS3 selector to a form element
* @return Object
*/
this.getFormValues = function getFormValues(selector) {
var form = this.findOne(selector);
var values = {};
this.getFormValues = function getFormValues(form) {
var self = this;
[].forEach.call(form.elements, function(element) {
var name = element.getAttribute('name');
if (name && !values[name]) {
values[name] = self.getFieldValue(name, {formSelector: selector});
var values = {}, checked = {};
if (!(form instanceof HTMLElement) || typeof form === "string") {
this.log("attempting to fetch form element from selector: '" + form + "'", "info");
try {
form = this.findOne(form);
} catch (e) {
this.log("invalid form selector provided: '" + form + "'");
return {};
}
}
[].forEach.call(form.elements, function(elm) {
var name = elm.getAttribute('name');
var value = self.getField(elm);
var multi = !!value && elm.hasAttribute('type') &&
elm.type === 'checkbox' ? elm.value : value;
if (!!name && value !== null && !(elm.type === 'checkbox' && value === false)) {
if (typeof values[name] === "undefined") {
values[name] = value;
checked[name] = multi;
} else {
if (!Array.isArray(values[name])) {
values[name] = [checked[name]];
}
values[name].push(multi);
}
}
});

@@ -711,2 +706,45 @@ return values;

/**
* Makes selector by defined type XPath, Name or Label. Function has same result as selectXPath in Casper module for
* XPath type - it makes XPath object.
* Function also accepts name attribut of the form filed or can select element by its label text.
*
* @param String selector Selector of defined type
* @param String|null type Type of selector, it can have these values:
* css - CSS3 selector - selector is returned trasparently
* xpath - XPath selector - return XPath object
* name|names - select input of specific name, internally covert to CSS3 selector
* label|labels - select input of specific label, internally covert to XPath selector. As selector is label's text used.
* @return String|Object
*/
this.makeSelector = function makeSelector(selector, type){
type = type || 'xpath'; // default type
var ret;
if (typeof selector === "object") { // selector object (CSS3 | XPath) could by passed
selector = selector.path;
}
switch (type) {
case 'css': // do nothing
ret = selector;
break;
case 'name': // convert to css
case 'names':
ret = '[name="' + selector + '"]';
break;
case 'label': // covert to xpath object
case 'labels':
ret = {type: 'xpath', path: '//*[@id=string(//label[text()="' + selector + '"]/@for)]'};
break;
case 'xpath': // covert to xpath object
ret = {type: 'xpath', path: selector};
break;
default:
throw new Error("Unsupported selector type: " + type);
}
return ret;
};
/**
* Dispatches a mouse event to the DOM element behind the provided selector.

@@ -722,3 +760,3 @@ *

var elem = this.findOne(selector);
if (!elem) {
if (!elem || !this.elementVisible(elem)) {
this.log("mouseEvent(): Couldn't find any element matching '" +

@@ -873,20 +911,52 @@ selector + "' selector", "error");

/**
* Sets a field (or a set of fields) value. Fails silently, but log
* Sets a value to form element by CSS3 or XPath selector.
*
* With makeSelector() helper can by easily used with name or label selector
* @exemple setFieldValue(this.makeSelector('email', 'name'), 'value')
*
* @param String|Object CSS3|XPath selector
* @param Mixed Input value
* @param HTMLElement|String|null scope Element to search child elements within
* @return bool
*/
this.setFieldValue = function setFieldValue(selector, value, scope) {
var self = this;
var fields = this.findAll(selector, scope);
var values = value;
if (!Array.isArray(value)) {
values = [value];
}
if (fields && fields.length > 1) {
fields = [].filter.call(fields, function(elm){
if (elm.nodeName.toLowerCase() === 'input' &&
['checkbox', 'radio'].indexOf(elm.getAttribute('type')) !== -1) {
return values.indexOf(elm.getAttribute('value')) !== -1;
}
return true;
});
[].forEach.call(fields, function(elm) {
self.setField(elm, value);
});
} else {
this.setField(fields[0], value);
}
return true;
};
/**
* Sets a field value. Fails silently, but log
* error messages.
*
* @param HTMLElement|NodeList field One or more element defining a field
* @param mixed value The field value to set
* @param HTMLElement field One element defining a field
* @param mixed value The field value to set
*/
this.setField = function setField(field, value) {
/*eslint complexity:0*/
var logValue, fields, out;
var logValue, out, filter;
value = logValue = value || "";
if (field instanceof NodeList || field instanceof Array) {
fields = field;
field = fields[0];
}
if (!(field instanceof HTMLElement)) {
var error = new Error('Invalid field type; only HTMLElement and NodeList are supported');
var error = new Error('setField: Invalid field ; only HTMLElement is supported');
error.name = 'FieldNotFound';

@@ -900,3 +970,2 @@ throw error;

}
this.log('Set "' + field.getAttribute('name') + '" field value to ' + logValue, "debug");

@@ -910,45 +979,16 @@

var nodeName = field.nodeName.toLowerCase();
switch (nodeName) {
case "input":
var type = field.getAttribute('type') || "text";
switch (type.toLowerCase()) {
case "checkbox":
if (fields.length > 1) {
var values = value;
if (!Array.isArray(values)) {
values = [values];
}
Array.prototype.forEach.call(fields, function _forEach(f) {
f.checked = values.indexOf(f.value) !== -1 ? true : false;
});
} else {
field.checked = value ? true : false;
}
break;
case "file":
throw {
name: "FileUploadError",
message: "File field must be filled using page.uploadFile",
path: value
};
case "radio":
if (fields) {
if (fields.length > 1) {
Array.prototype.forEach.call(fields, function _forEach(e) {
e.checked = e.value === value;
});
} else {
field.checked = value ? true : false;
}
} else {
out = 'Provided radio elements are empty';
}
break;
default:
field.value = value;
break;
}
filter = String(field.getAttribute('type') ? field.getAttribute('type') : field.nodeName).toLowerCase();
switch (filter) {
case "checkbox":
case "radio":
field.checked = value ? true : false;
break;
case "file":
throw {
name: "FileUploadError",
message: "File field must be filled using page.uploadFile",
path: value,
id: field.id || null
};
break;
case "select":

@@ -982,11 +1022,6 @@ if (field.multiple) {

break;
case "textarea":
default:
field.value = value;
break;
default:
out = 'Unsupported field type: ' + nodeName;
break;
}
// firing the `change` and `input` events
['change', 'input'].forEach(function(name) {

@@ -1017,3 +1052,13 @@ var event = document.createEvent("HTMLEvents");

};
/**
* Checks if all elements matching a given selector are visible in remote page.
*
* @param String selector CSS3 selector
* @return Boolean
*/
this.allVisible = function allVisible(selector) {
return [].every.call(this.findAll(selector), this.elementVisible);
};
};
})(typeof exports === "object" && !(exports instanceof Element) ? exports : window);

@@ -559,5 +559,5 @@ /*!

var actual = this.casper.evaluate(function(inputName, options) {
return __utils__.getFieldValue(inputName, options);
}, input, options);
var actual = this.casper.evaluate(function(inputName) {
return __utils__.getFieldValue(__utils__.makeSelector(inputName,'name'));
}, input);

@@ -577,5 +577,5 @@ return baseFieldAssert.call(this, input, expected, actual, message);

"use strict";
var actual = this.casper.evaluate(function(inputName, cssSelector) {
return __utils__.getFieldValue(inputName, {inputSelector: cssSelector});
}, null, cssSelector);
var actual = this.casper.evaluate(function(inputName) {
return __utils__.getFieldValue(__utils__.makeSelector(inputName,'css'));
}, cssSelector);

@@ -595,5 +595,5 @@ return baseFieldAssert.call(this, null, expected, actual, message);

"use strict";
var actual = this.casper.evaluate(function(inputName, xPathSelector) {
return __utils__.getFieldValue(inputName, {inputXPath: xPathSelector});
}, null, xPathSelector);
var actual = this.casper.evaluate(function(inputName) {
return __utils__.getFieldValue(__utils__.makeSelector(inputName,'xpath'));
}, xPathSelector);

@@ -1044,2 +1044,21 @@ return baseFieldAssert.call(this, null, expected, actual, message);

/**
* Asserts that all elements matching selector expression are currently visible.
* Fails if even one element is not visible.
*
* @param String expected selector expression
* @param String message Test description
* @return Object An assertion result object
*/
Tester.prototype.assertAllVisible = function assertAllVisible(selector, message) {
"use strict";
return this.assert(this.casper.allVisible(selector), message, {
type: "assertAllVisible",
standard: "All elements matching selector are visible",
values: {
selector: selector
}
});
};
/**
* Prints out a colored bar onto the console.

@@ -1046,0 +1065,0 @@ *

@@ -470,3 +470,3 @@ /*!

}).filter(function(ext) {
return ext !== 'json';
return ext === 'js';
});

@@ -473,0 +473,0 @@ return isString(ext, "string") && valid.indexOf(ext) !== -1;

@@ -208,7 +208,6 @@ /*!

XUnitExporter.prototype.setupDocument = function() {
// Since we are outputting XML, let's do our own document type
var documentType = document.implementation.createDocumentType("casperjs", "-//CasperJS//XUnit Test Results", "testsuites");
this._xmlDocument = document.implementation.createDocument("", "", documentType);
// Note that we do NOT use a documentType here, because validating
// parsers try to fetch the (non-existing) DTD and fail #1528
this._xmlDocument = document.implementation.createDocument("", "");
this._xml = this._xmlDocument.appendChild(this._xmlDocument.createElement("testsuites"));
};
{
"name": "casperjs",
"description": "A navigation scripting & testing utility for PhantomJS and SlimerJS",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [

@@ -6,0 +6,0 @@ "phantomjs",

@@ -16,2 +16,3 @@

png: {type: 'image/png', binMode: true},
notype: {type: null, binMode: false},
_default: {type: 'application/octet-stream', binMode: true}

@@ -47,3 +48,5 @@ };

headers['Content-Type'] = contentType.type;
if (contentType.type) {
headers['Content-Type'] = contentType.type;
}
binMode = contentType.binMode;

@@ -50,0 +53,0 @@

/*eslint strict:0*/
casper.test.begin('Casper.bypass() can bypass a step', 1, function(test) {
casper.test.begin('Casper.bypass() can bypass a step', 2, function(test) {
casper.start();

@@ -7,3 +7,5 @@ casper.then(function(){

});
casper.bypass(1).run(function() {
casper.once("step.bypassed", function(step) {
test.pass("step.bypassed event has been catched");
}).bypass(1).run(function() {
test.pass("Step has been bypassed");

@@ -107,2 +109,1 @@ test.done();

});

@@ -41,1 +41,12 @@ /*eslint strict:0*/

});
casper.test.begin('fetchText() handles plain texts', 1, function(test) {
casper.start().then(function() {
this.setContent('This is a plain text.');
test.assertEquals(this.fetchText('html'), 'This is a plain text.',
'Casper.fetchText() handles plain texts');
});
casper.run(function() {
test.done();
});
});
/*eslint strict:0*/
var fs = require('fs');
var selectXPath = require('casper').selectXPath;

@@ -337,1 +338,108 @@ function testFormValues(test) {

});
//
// setFieldValue() tests
//
casper.test.begin('setFieldValue() tests with css3 selector and form', 9, function(test) {
casper.start('tests/site/form.html', function() {
var data = {
"input[name='email']": 'chuck@norris.com',
"input[name='password']": 42,
"textarea[name='content']": 'Am watching thou',
"input[name='check']": true,
"input[name='choice']": 'no',
"select[name='topic']": 'bar',
"select[name='multitopic']": ['bar', 'car'],
"input[name='checklist[]']": ['1', '3'],
"input[name='strange']": "very"
};
for (var selector in data){
this.setFieldValue(selector, data[selector], 'form[action="result.html"]');
}
testFormValues(test);
});
casper.run(function() {
test.done();
});
});
casper.test.begin('setFieldValue() tests with XPath selector', 9, function(test) {
casper.start('tests/site/form.html', function() {
var data = {
'//input[@name="email"]': 'chuck@norris.com',
'//input[@name="password"]': 42,
'//textarea[@name="content"]': 'Am watching thou',
'//input[@name="check"]': true,
'//input[@name="choice"]': 'no',
'//select[@name="topic"]': 'bar',
'//select[@name="multitopic"]': ['bar', 'car'],
'//input[@name="checklist[]"]': ['1', '3'],
'//input[@name="strange"]': "very"
};
for (var selector in data){
this.setFieldValue( selectXPath(selector), data[selector]);
}
testFormValues(test);
});
casper.run(function() {
test.done();
});
});
casper.test.begin('setFieldValueName() tests', 9, function(test) {
casper.start('tests/site/form.html', function() {
var data = {
email: 'chuck@norris.com',
password: 42,
content: 'Am watching thou',
check: true,
choice: 'no',
topic: 'bar',
multitopic: ['bar', 'car'],
'checklist[]': ['1', '3'],
strange: "very"
};
for (var selector in data){
this.setFieldValueName(selector, data[selector]);
}
testFormValues(test);
});
casper.run(function() {
test.done();
});
});
casper.test.begin('setFieldValueLabel() tests', 9, function(test) {
casper.start('tests/site/form.html', function() {
var data = {
Email: 'chuck@norris.com',
Password: 42,
Content: 'Am watching thou',
Check: true,
No: true,
Topic: 'bar',
Multitopic: ['bar', 'car'],
"1": true,
"3": true,
Strange: "very"
};
for (var selector in data){
this.setFieldValueLabel(selector, data[selector]);
}
testFormValues(test);
});
casper.run(function() {
test.done();
casper.result.log = [];
});
});
// end setFieldValue() test

@@ -10,2 +10,3 @@ /*eslint strict:0*/

casper.result.log = [];
casper.options.logLevel = 'info';

@@ -12,0 +13,0 @@ casper.options.verbose = false;

/*eslint strict:0, max-statements:0*/
casper.test.begin('mouseEvent() tests', 16, function(test) {
casper.on('remote.message',function(e){
console.log(e);
});
casper.test.begin('mouseEvent() tests', 20, function(test) {
casper.start('tests/site/mouse-events.html', function() {

@@ -12,2 +16,4 @@ test.assert(this.mouseEvent('mousedown', '#test1'), 'Casper.mouseEvent() can dispatch a mousedown event');

test.assert(this.mouseEvent('mouseout', '#test8'), 'Casper.mouseEvent() can dispatch a mouseout event handled by unobstrusive js');
test.assertFalsy(this.mouseEvent('click', '#test9'), 'Casper.mouseEvent() can dispatch a click event on an hidden element');
test.assertFalsy(this.mouseEvent('click', '#test10'), 'Casper.mouseEvent() can dispatch a click event handled by unobstrusive js on an hidden element ');
});

@@ -25,2 +31,4 @@

test.assert(results.test8, 'Casper.mouseEvent() triggered mouseout via unobstrusive js');
test.assertFalsy(results.test9, 'Casper.mouseEvent() triggered click on an hidden element');
test.assertFalsy(results.test10, 'Casper.mouseEvent() triggered click on an hidden element via unobstrusive js');
});

@@ -27,0 +35,0 @@

@@ -38,4 +38,5 @@ /*eslint strict:0*/

casper.test.begin('eachThen() tests', 1, function(test) {
casper.test.begin('eachThen() tests', 2, function(test) {
var received = [];
var receivedFalsy = [];

@@ -49,7 +50,22 @@ casper.start().eachThen([1, 2, 3], function(response) {

casper.run(function() {
casper.then(function() {
test.assertEquals(received, [1, 2, 3],
'Casper.eachThen() passes item to step data');
});
casper.eachThen([false, 0, ''], function(response) {
if (!response) {
test.fail('No response received');
}
receivedFalsy.push(response.data);
});
casper.then(function() {
test.assertEquals(receivedFalsy, [false, 0, ''],
'Casper.eachThen() passes falsy items to step data');
});
casper.run(function() {
test.done();
});
});
/*eslint strict:0*/
var fs = require('fs');
var x = require('casper').selectXPath;
var selectXPath = require('casper').selectXPath;

@@ -42,5 +42,5 @@ function fakeDocument(html) {

// xpath
test.assert(clientutils.exists(x('//ul')),
test.assert(clientutils.exists( selectXPath('//ul')),
'ClientUtils.exists() checks that an element exist using XPath');
test.assertNot(clientutils.exists(x('//ol')),
test.assertNot(clientutils.exists( selectXPath('//ol')),
'ClientUtils.exists() checks that an element exist using XPath');

@@ -68,3 +68,3 @@ fakeDocument(null);

'ClientUtils.findAll() can find matching DOM elements within a given scope');
test.assertType(clientutils.findAll(x('//li'), scope), 'array',
test.assertType(clientutils.findAll( selectXPath('//li'), scope), 'array',
'ClientUtils.findAll() can find matching DOM elements using XPath within a given scope');

@@ -86,3 +86,3 @@ fakeDocument(null);

'ClientUtils.findOne() can find a matching DOM element within a given scope');
test.assertType(clientutils.findOne(x('//li'), scope), 'htmllielement',
test.assertType(clientutils.findOne( selectXPath('//li'), scope), 'htmllielement',
'ClientUtils.findOne() can find a matching DOM element using XPath within a given scope');

@@ -105,3 +105,3 @@ fakeDocument(null);

// XPath selector
var xpathSelector = clientutils.processSelector(x('//li[text()="blah"]'));
var xpathSelector = clientutils.processSelector( selectXPath('//li[text()="blah"]'));
test.assertType(xpathSelector, 'object',

@@ -256,1 +256,36 @@ 'ClientUtils.processSelector() can process a XPath selector');

});
casper.test.begin('ClientUtils.makeSelector() tests', 8, function(test) {
var clientutils = require('clientutils').create();
// CSS selector
var cssSelector = clientutils.makeSelector('#css3selector', 'css');
test.assertEquals(cssSelector, '#css3selector',
'ClientUtils.makeSelector() can process a CSS3 selector');
// XPath selector
var xpathSelector = clientutils.makeSelector('//li[text()="blah"]', 'xpath');
test.assertType(xpathSelector, 'object',
'ClientUtils.makeSelector() can process a XPath selector');
test.assertEquals(xpathSelector.type, 'xpath',
'ClientUtils.makeSelector() can process a XPath selector');
test.assertEquals(xpathSelector.path, '//li[text()="blah"]',
'ClientUtils.makeSelector() can process a XPath selector');
// Name selector
var nameSelector = clientutils.makeSelector('parameter', 'names');
test.assertEquals(nameSelector, '[name="parameter"]',
'ClientUtils.makeSelector() can process a XPath selector');
// Label selector
var labelSelector = clientutils.makeSelector('Male', 'labels');
test.assertType(labelSelector, 'object',
'ClientUtils.makeSelector() can process a Label selector');
test.assertEquals(labelSelector.type, 'xpath',
'ClientUtils.makeSelector() can process a Label selector');
test.assertEquals(labelSelector.path, '//*[@id=string(//label[text()="Male"]/@for)]',
'ClientUtils.makeSelector() can process a Label selector');
test.done();
});
/*eslint strict:0, max-statements:0*/
var fs = require('fs');
casper.test.begin('Common assertions tests', 47, function(test) {
casper.test.begin('Common assertions tests', 50, function(test) {
casper.start('tests/site/index.html', function() {

@@ -66,2 +66,6 @@ test.assertTextExists('form', 'Tester.assertTextExists() checks that page body contains text');

test.assertVisible('img', 'Tester.assertVisible() works as expected');
test.assertAllVisible('li', 'Tester.assertAllVisible() passes as expected');
test.assertFail(function(){
test.assertAllVisible('img, p#hidden');
}, 'Tester.assertAllVisible() fails as expected.');
test.assertNotVisible('p#hidden', 'Tester.assertNotVisible() works as expected');

@@ -68,0 +72,0 @@ test.assertInvisible('p#hidden', 'Tester.assertInvisible() works as expected [alias]');

@@ -312,3 +312,3 @@ /*eslint strict:0, max-statements:0*/

casper.test.begin('isJsFile() tests', 5, function(test) {
casper.test.begin('isJsFile() tests', 4, function(test) {
var testCases = {

@@ -318,3 +318,3 @@ '': false,

'plop': false,
'gniii.coffee': '.coffee' in require.extensions,
// 'gniii.coffee': '.coffee' in require.extensions,
'script.js': true

@@ -321,0 +321,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc