Randall Beatty
Intermediate Front-end Developer at
tbk Creative
Erin DeGroote
Junior Front-end Developer at
tbk Creative
A navigation scripting and testing utility for PhantomJS.
A headless browser (no GUI)
this.fill('form#contact-form', {
'input[name="email"]': 'randall@tbkcreative.com'
'textarea[name="message"]': 'Hello world'
}, false);fillSelectors() — Fills form fields with given values and optionally submits it
fillLabels() — Fills a form with provided field values using associated label text. Fields are referenced by label content values
this.fillLabels('form#contact-form', {
Email: 'randall@tbkcreative.com',
Message: 'Hello world',
}, true);casper.then(function() {
this.click('.btn');
});click() - Performs a click on the element matching the provided selector expression.
clickLabel() - Clicks on the first DOM element found containing label text
casper.then(function() {
this.clickLabel('Button Text', 'a');
});test.assert(true, 'true');
test.assertExists('.name');
test.assertDoesntExist('.name');
test.assertEquals(1 + 1, 2);
test.assertElementCount('ul', 1);
test.assertNotVisible('.name');
test.assertSelectorHasText('title', 'tbk');
...and lots moreAssertions - The provided condition strictly resolves to a boolean true
casper.start('http://yoursite.com/1');
casper.thenOpen('http://yoursite.com/2');
casper.back(); // http://yoursite.com/1
casper.forward(); // http://yoursite.com/2back() and forward() — move a step back or forward in browser’s history
casper.start('http://yoursite.com/', function() {
this.captureSelector('screenshot.png', '#container');
});download() — saves a remote resource onto
file system
casper.start('http://yoursite.com/', function() {
var url = 'http://yoursite.com/about';
this.download(url, 'about.html');
});captureSelector() — take screenshot of a page or element and save files to target location
casper.test.begin( name, function(test) {
casper.start('about:blank');
generate_attribute_sets(options).forEach(function(attribute_set, counter) {
var shortcode = generate_shortcode(attribute_set, template);
casper.thenOpen(root + '/dev/tbk-base/src/shortcode-tester
/?shortcode=' + encodeURIComponent(shortcode), function() {
casper.echo( "\n" + ( counter + 1 ) + ": " + root +
'/dev/tbk-base/src/shortcode-tester/?shortcode=' + encodeURIComponent(shortcode) );
casper.echo(shortcode);
attribute_set.tests.forEach(function(test_function) {
test_function(test);
});
});
});
});atts: {
text_position: 'center',
},
tests: function(test) {
test.assertExists('.center');
test.assertDoesntExist('.top-left');
test.assertDoesntExist('.top-center');
test.assertDoesntExist('.top-right');
test.assertDoesntExist('.middle-left');
test.assertDoesntExist('.middle-right');
test.assertDoesntExist('.bottom-left');
test.assertDoesntExist('.bottom-center');
test.assertDoesntExist('.bottom-right');
}[exec] [37;42;1mPASS 4176 tests executed in 825.161s, 4176 passed, 0 failed, 0 dubious, 0 skipped.[0m*Go easy, we're still learning too