CasperJS is no longer actively maintained. Navigation scripting and testing utility for PhantomJS and SlimerJS

Overview

CasperJS

Build Status

Important note: the master branch hosts the development version of CasperJS, which is now pretty stable and should be the right version to use if you ask me. Users interested in a pretty stable, recent version working with PhantomJS 2.0 and newer should choose the packaged 1.1.0 and following releases.

The 1.0 branch is now obsolete. Please note that

  • it is only recommended if you need to keep old production tests running that could do with the now unmaintained PhantomJS 1.9
  • 1.0 tests unfortunately have to be run manually using the casperjs selftest command

Note that all versions up to and including 1.1-beta3 do not support PhantomJS 2.0 and newer.

The complete documentation for the current releases is hosted on docs.casperjs.org.

CasperJS is a navigation scripting & testing utility for PhantomJS and SlimerJS (still experimental). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks such as:

Browse the sample examples repository. Don't hesitate to pull request for any cool example of yours as well!

Read the full documentation on casperjs documentation website.

Subscribe to the project mailing-list

Follow the CasperJS project on twitter and Google+.

Show me some code!

First install CasperJS, we'll use 1.1 beta here.

Sample test to see if some dropdown can be opened:

casper.test.begin('a twitter bootstrap dropdown can be opened', 2, function(test) {
    casper.start('http://getbootstrap.com/2.3.2/javascript.html#dropdowns', function() {
        test.assertExists('#navbar-example');
        this.click('#dropdowns .nav-pills .dropdown:last-of-type a.dropdown-toggle');
        this.waitUntilVisible('#dropdowns .nav-pills .open', function() {
            test.pass('Dropdown is open');
        });
    }).run(function() {
        test.done();
    });
});

Run the script:

Support

Help request. If you're stuck using CasperJS and don't understand how to achieve something, please ask on the mailing-list first. If the discussion reveals that you have found a real issue that might need a change within CasperJS, file an issue.

Filing issues. It takes a lot of time to review, validate, and de-duplicate filed issues. This time could be spent better on actually improving on CasperJS. Filing an issue might be a helpful contribution, but we expect you to read our CONTRIBUTING.md guidelines first.

Professional Support. Need help with getting CasperJS up and running? Got a time-consuming problem you want to get solved quickly?

Try to find someone to address your specific problem and post a reward at bountysource.

If you need to have a known issue resolved and don't have the time or skills to do it on your own, you could post a reward for any open issue directly.

Contributing

Contributing code

Please read the CONTRIBUTING.md file contents.

Contributing documentation

CasperJS's documentation is written using the Markdown format, and hosted on Github thanks to the Github Pages Feature.

To view the source files on github, head to the gh-pages branch, and check the documentation's README for further instructions.

Team

License

MIT

Comments
  • refs #987 - Support Phantomjs 2.0

    refs #987 - Support Phantomjs 2.0

    PhantomJS 2.0 (non-develop), branch: master, latest revision (a2912c216d06df4d8b51f12ad4082a48c5fc7ba6)

    casperjs selftest
    ...
    ...
    PASS 1022 tests executed in 25.746s, 1022 passed, 0 failed, 0 dubious, 5 skipped.
    

    this is very small victory ;-)

    Bud, problem is with Phantomjs. For fully support you must cherry-picked these revision from my repository:

    • build on Yosemite https://github.com/rdpanek/phantomjs/commit/c8abe25ce09bfdac995ef9970efe582ad9a79ee5
    • and fix with webpage.uploadFile bug https://github.com/rdpanek/phantomjs/commit/cb181f564e20b99138cebc3d9194850db4617b6e

    This is heavy for production use, but please to code review.

    Next steps:

    • We need to go through all the tests and update.
    • We need to comapre a new features in Phantom and adding to Casper.
    Enhancement PhantomJS 
    opened by rdpanek 47
  • refs #803 - Add option to create a new WebPage instance from casper

    refs #803 - Add option to create a new WebPage instance from casper

    Currently casperjs does not handle closing a page and creating a new page object.

    If user does a casper.page.close() there is no option to create a new page object.

    With this change we can use a casper.page = casper.newPage()

    Enhancement Qualified 
    opened by ilangv 41
  • Support for phantomjs 2.0.0 and 2.0.1 pre-release with fileupload bugfix

    Support for phantomjs 2.0.0 and 2.0.1 pre-release with fileupload bugfix

    This PR contains:

    • the changes contained in https://github.com/n1k0/casperjs/pull/1351 to make tests pass for slimerjs
    • lots of adaptations to the test suites to cater for changes in phantomjs 2.0.0 output (stack traces and syntax errors)
    • a fix to the patchRequire logic such that it will be applied to phantomjs 2

    This closes / supersedes https://github.com/n1k0/casperjs/pull/1310, https://github.com/n1k0/casperjs/pull/1137, https://github.com/n1k0/casperjs/pull/1173, https://github.com/n1k0/casperjs/pull/1291, https://github.com/n1k0/casperjs/pull/1189, https://github.com/n1k0/casperjs/pull/1351, https://github.com/n1k0/casperjs/issues/1204, #775.

    opened by istr 35
  • Introducing Casper.blockStep

    Introducing Casper.blockStep

    There exists circumstances where the next CasperJS step executes too early, causing false positives for failures in subsequent testing.

    This commit introduces Casper.blockStep(), also integrated into click() and clickLabel(). Developers will now be able to give CasperJS a hint about the nature of a click, and expect CasperJS to block execution of its next step until some not-yet-started behaviour actually starts and completes (today, we're concerned about loadInProgress and navigtationRequested -- pendingWait exists, but I can't think of why I'd want to invoke blockStep using that reason).

    It is relatively easy to maintain if new reasons for blocking the next step are created in the future; just add a new case for switch within blockStep(). It is also possible to directly call blockStep(), but a developer would typically be better just directly setting Casper.navigationRequested, or Casper.loadInProgress, or Casper.pendingWait.

    The idea of introducing blockStep() tied into click() and clickLabel() is so that we express the whole thing as a single statement.

    This usage is probably the generalized version:

    Casper.click("#that_button", "loadInProgress");
    

    This usage is probably more specifically looking at navigation of the _top frame (isMainFrame in CasperJS code):

    Casper.click("#that_button", "navigationRequested");
    
    Enhancement Needs Update ARCHIVE 
    opened by starlocke 34
  • add json configuration option for tests

    add json configuration option for tests

    • provide a cli argument for config.json file
    • parse arguments & options from config.json
    • ensure config.json is valid and can be required
    • ensure args & opts are stored back in phantom.casperArgs.raw
    • fixes #745
    • a config.json can look like:
        {
          "includes": [
            "inc1.js",
            "inc2.js"
          ],
          "log-level": "debug",
          "paths": [
            "test.js",
            "sub1"
          ],
          "post": [
            "post1.js",
            "post2.js"
          ],
          "pre": [
            "pre1.js",
            "pre2.js"
          ],
          "verbose": true,
          "xunit": "results.xml"
        }
    
    • tests can be run using: $ casperjs test ./config.json
    • note that, the config file is not a key word argument, since there are no additional arguments that you need to pass into the cli, if you provide a config.json.
    Enhancement PR Needs Update ARCHIVE 
    opened by r8k 32
  • Bump to version 1.1.0

    Bump to version 1.1.0

    I would like to publish 1.1.0-beta6, mainly to publish the updated documentation at http://docs.casperjs.org/en/latest/ ("read the docs" updates when publishing a new release).

    @mickaelandrieu @BIGjuevos Please have a look at https://github.com/n1k0/casperjs/releases to review the draft entry and see if you are ok with this. Thank you.

    opened by istr 30
  • [HOLD]

    [HOLD] "link_text" Feature

    Hello

    I have write a new feature : "link_text". The feature adds a new selector preconize in webdriver protocols.

    SelfTests OK. Documentations updated.

    I'm a newbee in github . when I use the command : "git push origin linkText" - it is forbidden

    remote: Permission to n1k0/casperjs.git denied to jefleponot. fatal: unable to access 'https://github.com/n1k0/casperjs.git/': The requested URL returned error: 403

    So I send it to my clone repository. Is it the correct way ?

    Please Help me.

    opened by jefleponot 29
  • Rework of the casperjs.org website

    Rework of the casperjs.org website

    Basically, pulled in bootstrap. Many things from free CDNs. Deleted everything else except the minimalistic (figured we don't need the cruft).

    In support of: #1532

    Pinging @istr, @mickaelandrieu, and @n1k0 for this one for their input. There anything I missed or am legally required to add?

    The markup is at: https://github.com/BIGjuevos/casperjs/blob/54cbb14524e6ebbb8bfd8e02929d371b53a45bb8/index.html

    The style is at:https://github.com/BIGjuevos/casperjs/blob/54cbb14524e6ebbb8bfd8e02929d371b53a45bb8/css/casper.css

    Full Site

    Responsive Site:

    Enhancement Website 3 - Done 
    opened by BIGjuevos 22
  • add features for asynchronous downloads

    add features for asynchronous downloads

    To solve asynschronous downloads that does work with phantomjs v2 (issue : Synchronous XHR causing zero byte file downloads #1342 ), there is a proposal PR

    for @langholz and @istr , thanks to your specifications.

    PS : operation synchronously javascript is simply an absurdity because it inhibits the language spirit. PS : PS : Could it be possible that a great tools as CasperJS be written to use asynchronous methods (http://phantomjs.org/api/webpage/method/evaluate-async.html) We could use it in more domains like "chrome extension tabs" : https://developer.chrome.com/extensions/tabs#method-executeScript

    Best Regards jef

    Enhancement Controversial ARCHIVE 
    opened by jefleponot 22
  • fix for evaluate function. in case if user passes one array argument …

    fix for evaluate function. in case if user passes one array argument …

    hey guys. here is a fix for evaluate function. in case if user passes one array argument with one object. evaluate converted this array to object instead return original array with one object.

    example

    let mockArray = [];
    
    //any actions
    mockArray.push({
      name: 'casper'
    });
    casper.evaluate(function (arr) {
           //I expect that arr = [{name: 'casper'}]
           //but it returns {name:'casper'}
           //so my fix is for this case, to return [{name: 'casper'}] instead of {name:'casper'}
     }, mockArray);
    
    opened by Marshevskyy 21
  • Add keyboardEvent methods to emulate keyboard events

    Add keyboardEvent methods to emulate keyboard events

    I needed to simulate keyboard events to test an autocomplete field, so I copy-pasted mouseEvent to create keyboardEvent. Works for me but need more tests, I know.

    opened by clochix 21
Releases(1.1.4-2)
  • 1.1.4-2(Nov 18, 2017)

    Important Changes and Bugfixes

    • visible element can't be critical for click trigger
    • added new slimerJS feature
    • casperjs.exe works with old .Net Framework
    • updated cli.rst to properly format sample code block
    • updated quickstart.rst with more info on node
    • updated documentation to include information about the setMaxListener…
    • updated events and filters docs
    • updated 404 and 500 errors checker

    Enhancements

    • improved frame management and resolve mouse position into frames
    • fixed sendKeys reset option with content-editables
    Source code(tar.gz)
    Source code(zip)
  • 1.1.4-1(Apr 25, 2017)

    Important Changes and Bugfixes

    • casperjs.exe works with old .Net Framework
    • improve frame management and resolve mouse position into frames

    Enhancements

    • clearMemoryCache add for Phantomjs
    • waitForExec provide program execution ...
    Source code(tar.gz)
    Source code(zip)
  • 1.1.4(Mar 9, 2017)

    Important Changes and Bugfixes

    • You can click on area tags (fixed regression)
    • You can navigate to frames without crash
    • visibility check is now fixed #1736
    • We have fixed popup on close crash.
    • errors are filtered on die method #1726

    Enhancements

    • New event added : page.filePicker (#1756)
    • add nodeJS launcher
    • unlimited XPath selector to fill all input fields #1759
    • Events are now completely usable with popups #1118
    • new parameters for command line are fitted #1735
    • support to custom headers in sendAJAX
    • SlimerJS event onLongRunningScript ...

    Additional Notes

    • With 1.1.4, We've recompiled the windows binary.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.4-beta(Mar 9, 2017)

    Important Changes and Bugfixes

    • You can click on area tags (fixed regression)
    • You can navigate to frames without crash
    • visibility check is now fixed #1736
    • We have fixed popup on close crash.
    • errors are filtered on die method #1726

    Enhancements

    • New event added : page.filePicker (#1756)
    • add nodeJS launcher
    • unlimited XPath selector to fill all input fields #1759
    • Events are now completely usable with popups #1118
    • new parameters for command line are fitted #1735
    • support to custom headers in sendAJAX
    • SlimerJS event onLongRunningScript ...

    Additional Notes

    • With 1.1.4, We've recompiled the windows binary.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Jul 22, 2016)

    Important Changes and Bugfixes

    • You can no longer click on hidden tags. In order to click on them, you must first make them visible. #1639 #1246
    • We accidentally removed support for coffeescript with 1.1.2 (#0e38b9), we've decided to bring it back. Apologies to those coffeescript lovers out there. #1642

    Enhancements

    • Say hello to download.error. A new lifecycle event for you to tie into. Thanks @TheGrandPackard #1647

    Additional Notes

    • Release 1.1.2 did not get a new compiled executable. With 1.1.3, We've recompiled the windows binary.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Jul 8, 2016)

    Important Changes & Bugfixes

    • Mouse events work on hidden element (#1246, #1245)
    • New method getPlainText() (#1590)
    • More robustness for stop.options.data (#1148,#1419)
    • Documentation Fixes (#1603,#1261,#1569,#1563,#1548,#503,#1553,#1556,#548,#1555,#1602)
    • Fixes for page.resource.* on slimer 0.10 (#1550)
    • Fix doctype for xml output (#1528,#1546,#1543)

    Enhancements

    • Normalizes methods (names, parameters), optimizes threats and simplifies maintenance of clientutils.js ( keeping all BC ). (#1583)
    • Additional functionality for wait* (#1488,#1493)
    • Add assertAllVisible (#1224)
    • New step.bypasses event (#1447)
    • NPM package is now slimmer due to ignoring not needed assets (#1637)

    General Things

    • We now have our own SlimerJS mirror for testing. Since it is hosted by GitHub, feel free to use as needed. This has helped with test stability.
    • PhantomsJS builds mirror was moved from BIGjuevos to casperjs organization. Since it is hosted by GitHub, feel free to use as needed. This has helped with test stability.

    A brand new website

    • If you haven't seen it yet, I highly encourage you to check it out!
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Apr 19, 2016)

  • 1.1.0(Apr 11, 2016)

    Important Changes & Bugfixes

    • yet another bugfix for passing options to the engine and tests (#1448, #1449, #1452)
    • fixed infinite loop in path resolving (#1479, #1483)
    • fixed issues with stale popups (#963, #978, #1095, #1174, #1303, #1354, #1490)
    • fixed issues with mouse events (#208, #1417)

    New features

    • option to create a new WebPage instance to address memory consumption issues (#803, #826)
    • multiple file uploads (#525, #1425)

    Minor fixes & enhancements

    • proper XML output for XUnit (#824, #1322, #1440, #1458, #1499)
    • allow to pass encoding (default: utf8) to openUrl (#1434)
    • improvements on spelling and documentation (#1203, #1355, #1366, #1454, #1459, #1462, #1468, #1470, #1477, #1489, #1497, #1498, #1501, #1504, #1508, #1509, #1510)
    • make fillForm chainable (#1256)
    • stabilized travis CI builds (#1499)
    • warn that PhantomJS 2.* does not support coffeescript (#1469)
    • minor tweak to eslint setup (#1515)
    • encoded URLs for PhantomJS 2.* (#1495)

    Known Issues

    Same as for 1.1-beta5: three of the self-tests fail reproducibly on Windows (#1427) (the same binary passes mono-based checks on travis, linux, OS/X)

    Source code(tar.gz)
    Source code(zip)
  • 1.1-beta5(Feb 5, 2016)

    Important Changes & Bugfixes

    This is a follow up release for 1.1-beta4 with two important fixes for Windows users

    • bugfix for passing options to the engine (#1384, #1389)
    • add re-compiled windows binary (#1426)

    Known Issues

    • three of the self-tests fail reproducibly on Windows (#1427) (the same binary passes mono-based checks on travis, linux, OS/X)
    Source code(tar.gz)
    Source code(zip)
  • 1.1-beta4(Feb 3, 2016)

    Important Changes & Bugfixes

    Because the last pre-release is over 2 years old, the list of changes and bug-fixes in this pre-release is rather long (362 commits ever since). A special thanks goes to all contributors making this update possible!

    Amongst others the most important change is the long awaited support for PhantomJS 2 that was extended to the official PhantomJS 2.1.1 release recently.

    Apart from that this pre-release integrates the following PRs for important bugfixes and changes:

    • bugfix for an element with an id having the value exports (#794)
    • bugfix for visibility check on inline-block elements (#855)
    • bugfix for non-functional back() and forward() calls (#924, #929, #930)
    • bugfix for --fail-fast option preventing emission of fail events (#923)
    • bugfix for resourceExists(): use string matching instead of regexp (#1033)

    New features

    • support for prependListener() (#766)
    • support for fillLabels() (#948)
    • support for rightclick() (#1169)
    • support for waitForAlert() (#748)

    Minor fixes & enhancements

    • XUnit output for gecko (#759)
    • improvements on dotNET support (#758, #765, #770,
    • sendKeys() works on content-editable elements (#620)
    • support for POSTing JSON objects with casper.open() (#832) with charset info (#840)
    • emit an event in casper.click() (#850)
    • mono / Windows: fix for white space in PATH (#851, #1166, #1171)
    • test input type email (#860)
    • support for input type select-multiple (#862)
    • support PhantomJS versions without require.paths (#774)
    • remove some spurious fs calls (#879)
    • check if javascriptEnabled before calling casper.evaluate() (#892)
    • make username / password usable in configureHttpAuth (#848)
    • use subprocess.call instead of os.exec to launch casperjs (#96, #875)
    • use this.page.framePlainText for non-HTML content (#926)
    • recursive node module lookup (#991)
    • named tests (#967)
    • temp files for rpm builds on BSD and OS/X (#1020)
    • respect page.zoomFactor while capturing (#918)
    • fetchText() can fetch values from input elements (#1079)
    • report correct type in assertNotVisible() (#1124)
    • support PhantomJS 1.9.8 (#1139, #1140)
    • support SlimerJS 0.9.5 (#1144)
    • bugfix for --concise option (#1110)
    • bugfix for missing Content-Type in response (#1071)
    • propagate waitFor timeout exception (#1183)
    • ConEmu color support (#1199)
    • use ESLint instead of JSHint (#1145, #1298, #1400)
    • pass extra args to thenEvaluate in thenOpenAndEvaluate (#1211)
    • make fetchText() return empty string on empty elements (#1217)
    • allow formfill() to find select element values by their option elements text as well (#1346)
    • bugfix for formfill() failing on numerical input values (#1289)
    • add --disk-cache-path option (#1380)
    • bugfix for the Function.bind shim (#1404)
    • updates to the documentation (#761, #769, #788, #799, #830, #834, #835, #837, #838, #886, #891, #893, #894, #905, #1002, #1011, #1013, #1019, #1029, #1064, #1073, #1092, #1113, #1120, #1153, #1175, #1209, #1238, #1284, #1315, #1335, #1341, #1370, #1359, #1399, #1403, #1406, #1409)
    • improvements on page layout (#947)
    • improvements on test suites (#984, #1201, #1349, #1369, #1387, #1388)
    Source code(tar.gz)
    Source code(zip)
  • 1.1-beta3(Nov 29, 2013)

    Important changes & bugfixes

    • Fixed #523 - Make CasperJS installable & usable from npm using:

      $ npm install casperjs
      

      Or if you want to install it globally on your system:

      $ npm install -g casperjs
      

      Notes:

      • Only 1.1 beta versions are installable from npm;
      • CasperJS is still not a NodeJS package, it needs either PhantomJS or SlimerJS to run.
    • Fixed #728 - Prevent overriding of preconfigured casper instance in a test environment

      This was a hard decision to make, but too many people just don't read the docs and create new casper instance in a test env, overriding the preconfigured one which creates cumbersome and hard to understand situation.

      Hopefully this change will inform users right from the place they read docs the most, fatal error messages.

    • Fixed #722 - Thrown step, complete and wait errors are no more silenced by default, though a new silentErrors Casper option is available if you want to reproduce the previous behavior

    • Fixed #715 - Enhanced element visibility computation method

    • Fixed #665 - Renamed --direct cli option to --verbose; --direct still works but is to be considered deprecated

    • Fixed #596 - added a new .NET launcher for Windows environments; just switch to using bin/casperjs.exe today

      Note: The previous batchbin/casperjs.bat executable is deprecated and won't be maintained anymore.

    New features

    • Added an --auto-exit=no test runner option and an exit tester event to hook on before runner exits (#704):

      // $ casperjs test test.js --auto-exit=no
      casper.test.on("exit", function() {
          console.log("exited");
      });
      
      casper.test.begin("sample", function(test) {
          test.assert(true);
          test.done();
      });
      
    • Added Casper#scrollTo() & Casper#scrollToBottom() scrolling helpers

    • Added a resource-error event on resource loading failure (#649)

    • Added a reset option to Casper#sendKeys()

    • Added CSS selector support to Tester#assertField()

    • Added a details property bag to waitFor.timeout events

    • Added a new improved RPM package build script

    Minor fixes & enhancements

    • Fixed #639 - withFrame() now switches back to parent frame instead of main one
    • Fixed #637 - checkStep() turns into an infinite loop when navigationLocked is true
    • Fixed #699 - getPageContent() throws error when content is not HTML
    • Fixed #666 - Ensure local options configuration override global configuration of Casper instance
    • Fixed #631 - better .bind() polyfill
    • Fixed #644 - better handling of deleted page objects
    • Fixed betterInstanceOf for Gecko (SlimerJS)
    • Fixed #711 - Better cli arguments parsing
    • Changed XUnit testsuite attribute duration to time to avoid errors on Jenkins
    • Updated python test runner to use the ENGINE_EXECUTABLE env var
    • Improved performance of the Python cli test suite
    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Nov 17, 2013)

  • 1.1-beta2(Sep 13, 2013)

    Changelog

    • Fixed a regression in require() preventing to require sub modules
    • Fixed untyped input tag was treated as invalid when filling forms
    • Added Phantomjs 1.9.2 to Travis build matrix
    • Added ability to require() nodejs modules
    • Added support for contenteditable in Casper#sendKeys()
    • Added Tester#assertInstanceOf()
    • Added new imgOptions parameter to Casper#capture*() methods
    • Added PDF exports of documentation
    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Jul 13, 2013)

    2013-07-13, v1.0.3

    Caveats

    This release is not compatible with PhantomJS >= 1.9. If you want to use later version of PhantomJS, please switch to the master branch.

    Bugfixes & enhancements

    • speeded up tests and wait* operations (expect average execution time to be divided by 4)
    • fixed #414 - better utils.cleanUrl()
    • fixed #438 - fixed Casper#getElementAttribute() broken compatibility with XPath selectors
    • fixed #484 - added support for the PhantomJS child_process module
    • fixes #457 - fill should not emit console messages
    • added support for child_process phantomjs module
    • peeded up tests and wait* methods execution
    Source code(tar.gz)
    Source code(zip)
  • 1.1-beta1(Jul 13, 2013)

    2013-07-13, v1.1-beta1

    1.0 users, an upgrading guide is available here.

    Important Changes & Caveats

    Minimum PhantomJS version

    PhantomJS 1.8.1 or later is required for 1.1.

    Experimental support of Gecko, with SlimerJS

    CasperJS can now be launched with SlimerJS instead of PhantomJS. It allows you to execute tests with the rendering engine of Firefox. Just launch CasperJS with the flag --engine=slimerjs.

    SlimerJS 0.8 or later is required.

    require() in custom modules

    CasperJS 1.1 now internally uses PhantomJS' native require() function, but it has side effect if you write your own casperjs modules; in any casperjs module, you now have to use the new global patchRequire() function first:

    // casperjs module code
    var require = patchRequire(require);
    // now you can require casperjs builtins
    var utils = require('utils');
    exports = {
        // ...
    };
    

    Note: you don't have to use patchRequire() in a standard casperjs script.

    Testing framework refactoring

    A new Tester.begin() method has been introduced to help organizing tests better:

    function Cow() {
        this.mowed = false;
        this.moo = function moo() {
            this.mowed = true; // mootable state: don't do that
            return 'moo!';
        };
    }
    
    // unit style synchronous test case
    casper.test.begin('Cow can moo', 2, function suite(test) {
        var cow = new Cow();
        test.assertEquals(cow.moo(), 'moo!');
        test.assert(cow.mowed);
        test.done();
    });
    
    // asynchronous test case
    casper.test.begin('Casperjs.org is navigable', 2, function suite(test) {
        casper.start('http://casperjs.org/', function() {
            test.assertTitleMatches(/casperjs/i);
            this.clickLabel('Testing');
        });
    
        casper.then(function() {
            test.assertUrlMatches(/testing\.html$/);
        });
    
        casper.run(function() {
            test.done();
        });
    });
    

    Tester#setUp() and Tester#tearDown() methods have been also added in order to ease the definition of operations to be performed before and after each test defined using Tester#begin():

    casper.test.setUp(function() {
        console.log('executed before each test');
    });
    
    casper.test.tearDown(function() {
        console.log('executed after each test');
    });
    

    Both can work asynchronously as well of you define the done argument:

    casper.test.setUp(function(done) {
        setTimeout(function() {
            console.log('asynchronously executed before each test');
            done();
        }, 1000);
    });
    
    casper.test.tearDown(function(done) {
        setTimeout(function() {
            console.log('asynchronously executed after each test');
            done();
        }, 1000);
    });
    

    Tester#begin() itself has also local setUp() and tearDown() capabilities if you pass it a configuration object instead of a function:

    casper.test.begin('range tests', 1, {
        setUp: function(test) {
            this.range.push(1);
            this.range.push(2);
            this.range.push(3);
        },
    
        tearDown: function(test) {
            this.range = [];
        },
    
        test: function(test) {
            test.assertEquals(this.range.length, 3);
            test.done();
        }
    });
    

    Scraping and testing are now better separated in CasperJS. That involves breaking up BC on some points though:

    • The Casper object won't be created with a test reference if not invoked using the casperjs test command, therefore the ability to run any test without calling it has been dropped. I know, get over it.
    • Passing the planned number of tests to casper.done() has been dropped as well, because done() may be never called at all when big troubles happen; rather use the new begin() method and provide the expected number of tests using the second argument:
    casper.test.begin("Planning 4 tests", 4, function(test) {
        [1, 2, 3, 4].forEach(function() {
            test.assert(true);
        });
        test.done();
    });
    

    Last, all the casper test suites have been upgraded to use the new testing features, you may want to have a look at the changes.

    Request abortion

    When using PhantomJS >=1.9.0, you can now abort outgoing requests:

    casper.on('page.resource.requested', function(requestData, request) {
        if (requestData.url.indexOf('http://adserver.com') === 0) {
            request.abort();
        }
    });
    

    Bugfixes & enhancements

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Jul 13, 2013)

    2013-02-08, v1.0.2

    • fixed #431 - fix for visible/waitUntilVisible when selector matches multiple elements
    • fixed #370 - mergeObjects failed to deep-clone when the target object did not contain the corresponding key
    • fixed #375 - Fixes a bug with getting form values for radio inputs, and introduces a minor optimization to avoid processing the same form fields more than once.
    • closed #373 - added RegExp support to Casper.waitForText()
    • fixed #368 - Remote JS error is thrown when a click target is missing after click()
    • merged PR #357 - fire the input event after setting input value (required to support angular.js apps)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Jul 13, 2013)

    2013-01-17, v1.0.1

    • fixed #336 - Test result duration may have an exotic value
    • Added casper.mouse.doubleclick()
    • fixed #343 - Better script checks
    • fixed an edge case with xunit export when phantom.casperScript may be not defined
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jul 13, 2013)

    2012-12-24, v1.0.0

    Important Changes & Caveats

    • PhantomJS 1.6.x support has been dropped. Both PhantomJS 1.7 & 1.8 will be supported.
    • the deprecated injector module has been removed from the codebase (RIP dude)
    • a 1.0 maintenance branch has been created
    • CasperJS 1.1 development is now taking place on the master branch

    Bugfixes & enhancements

    • fixed page.initialized event didn't get the initialized WebPage instance
    • fixed a bug preventing Casper.options.onPageInitialized() from being called
    • fixed #215 - fixed broken --fail-fast option creating an endless loop on error
    • fixed Tester.renderFailureDetails() which couldn't print failure details correctly in certain circumstances
    • fixed Casper.getHTML() wasn't retrieving active frame contents when using Casper.withFrame()
    • fixed #327 - event handler for page.confirm always returns true
    • merged PR #322 - Support number in Casper.withFrame()
    • fixed #323 - thenEvaluate() should be updated to take the same parameters as evaluate(), while maintaining backwards compatibility.
    • merged PR #319, fixed #209 - test duration has been added to XUnit XML result file.
    • Casper.userAgent() does not require the instance to be started anymore
    • dubious tests now have dedicated color & styling
    • added hint printing when a possible casperjs command call is detected
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC6(Jul 13, 2013)

    2012-12-14, v1.0.0-RC6

    I'm still expecting a 1.0 stable for Christmas. Feedback: bring it on.

    Important Changes & Caveats

    Added experimental support for frames

    A minimal convenient API has been added to Casper in order to ease the switch of current page context:

    casper.start('tests/site/frames.html', function() {
        this.test.assertTitle('CasperJS frameset');
    });
    
    casper.withFrame('frame1', function() {
        this.test.assertTitle('CasperJS frame 1');
    });
    
    casper.then(function() {
        this.test.assertTitle('CasperJS frameset');
    });
    

    Reverted to emulated mouse events

    Native mouse events didn't play well with (i)frames, because the computed element coordinates of the clicked element were erroneous.

    So programmatic mouse events are reintroduced back into this corrective RC until a better solution is found.

    Bugfixes & enhancements

    • merged #269 - Windows Batch script: fixed unsupported spaces in path and argument splitting
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC5(Jul 13, 2013)

    2012-12-10, v1.0.0-RC5

    I told you there won't be an 1.0.0-RC5? I lied. Expect 1.0 stable for Christmas, probably.

    Important Changes & Caveats

    Casper.evaluate() signature compatibility with PhantomJS

    Casper.evaluate() method signature is now compatible with PhantomJS' one, so you can now write:

    casper.evaluate(function(a, b) {
        return a === "foo" && b === "bar";
    }, "foo", "bar"); // true
    

    The old way to pass arguments has been kept backward compatible in order not to break your existing scripts though:

    casper.evaluate(function(a, b) {
        return a === "foo" && b === "bar";
    }, {a: "foo", b: "bar"}); // true
    

    Specification of planned tests

    In order to check that every planned test has actuall been executed, a new optional planned parameter has been added to Tester.done():

    casper.test.assert(true);
    casper.test.assert(true);
    casper.test.assert(true);
    casper.test.done(4);
    

    Will trigger a failure:

    fail: 4 tests planned, 3 tests executed.
    

    That's especially useful in case a given test script is abruptly interrupted leaving you with no obvious way to know it and an erroneous success status.

    The whole CapserJS test suite has been migrated to use this new feature.

    Experimental support for popups

    PhantomJS 1.7 ships with support for new opened pages — aka popups. CasperJS can now wait for a popup to be opened and loaded to react accordingly using the new Casper.waitForPopup() and Casper.withPopup() methods:

    casper.start('http://foo.bar/').then(function() {
        this.test.assertTitle('Main page title');
        this.clickLabel('Open me a popup');
    });
    
    // this will wait for the popup to be opened and loaded
    casper.waitForPopup(/popup\.html$/, function() {
        this.test.assertEquals(this.popups.length, 1);
    });
    
    // this will set the popup DOM as the main active one only for time the
    // step closure being executed
    casper.withPopup(/popup\.html$/, function() {
        this.test.assertTitle('Popup title');
    });
    
    // next step will automatically revert the current page to the initial one
    casper.then(function() {
        this.test.assertTitle('Main page title');
    });
    

    Casper.mouseEvent() now uses native events for most operations

    Native mouse events from PhantomJS bring a far more accurate behavior.

    Also, Casper.mouseEvent() will now directly trigger an error on failure instead of just logging an error event.

    Bugfixes & enhancements

    • fixed #308 & #309 - proper module error backtraces
    • fixed #306 - Raise an explicit error on invalid test path
    • fixed #300 - Ensure that findOne() and findAll() observe the scope for XPath expressions, not just when passed CSS selectors
    • fixed #294 - Automatically fail test on any runtime error or timeout
    • fixed #281 - Casper.evaluate() should take an array as context not object
    • fixed #266 - Fix tester module and its self tests
    • fixed #268 - Wrong message on step timeout
    • fixed #215 - added a --fail-fast option to the casper test command, in order to terminate a test suite execution as soon as any failure is encountered
    • fixed #274 - some headers couldn't be set
    • fixed #277 - multiline support in ClientUtils.echo()
    • fixed #282 - added support for remote client scripts loading with a new remoteScripts casper option
    • fixed #290 - add a simplistic RPM spec file to make it easier to (un)install casperjs
    • fixed utils.betterTypeOf() to properly handle undefined and null values
    • fixed Casper.die() and Casper.evaluateOrDie() were not printing the error onto the console
    • added JSON support to require()
    • added Tester.assertTruthy() and Tester.assertFalsy()
    • added Casper.sendKeys() to send native keyboard events to the element matching a given selector
    • added Casper.getFormValues() to check for the field values of a given form
    • added Tester.assertTextDoesntExist()
    • added Tester.assertFalse() as an alias of Tester.assertNot()
    • added page.resource.requested and page.resource.received events
    • added translate.js and translate.coffee samples
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC4(Jul 13, 2013)

    2012-10-31, v1.0.0-RC4

    Next version should be 1.0.0 stable.

    • fixed #261 - Impossible to require CoffeeScript modules
    • fixed #262 - Injecting clientScripts is not working
    • fixed #259 - enhanced Tester.assertField() method, which can now tests for other field types than inputs.
    • fixed Casper.getCurrentUrl() could misbehave with encoded urls
    • added Casper.echo() to print a message to the casper console from the remote DOM environment
    • added Casper.waitForText() to wait for a given text to be present in page HTML contents
    • added ClientUtils.getFieldValue()
    • Local CoffeeScript version has been upgraded to 1.4.0
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC3(Jul 13, 2013)

    2012-10-23, v1.0.0-RC3

    Important Changes & Caveats

    • the injector module is now deprecated, but kept for backward compatibility purpose.
    • BC BREAK: fixes #220, #237 - added a waitTimeout options, removed defaultWaitTimeout option.
    • BC BREAK (for the better): fixes #249 - default timeout functions don't die() anymore in tests
    • BC BREAK (for the better): merged #188 - Easy access to current response object; You can now access the current response object as the first parameter of step callbacks:
    require('casper').create().start('http://www.google.fr/', function(response) {
        require('utils').dump(response);
    }).run();
    

    That gives:

    $ casperjs dump-headers.js
    {
        "contentType": "text/html; charset=UTF-8",
        "headers": [
            {
                "name": "Date",
                "value": "Thu, 18 Oct 2012 08:17:29 GMT"
            },
            {
                "name": "Expires",
                "value": "-1"
            },
            // ... lots of other headers
        ],
        "id": 1,
        "redirectURL": null,
        "stage": "end",
        "status": 200,
        "statusText": "OK",
        "time": "2012-10-18T08:17:37.068Z",
        "url": "http://www.google.fr/"
    }
    

    To fetch a particular header by its name:

    require('casper').create().start('http://www.google.fr/', function(response) {
        this.echo(response.headers.get('Date'));
    }).run();
    

    That gives:

    $ casperjs dump-single-header.js
    Thu, 18 Oct 2012 08:26:34 GMT
    

    The documentation has been updated accordingly.

    Bugfixes & enhancements

    • merged #234 - New Windows Loader written in Batch. Python is no more a requirement for using CasperJS on Windows. New installation instructions are available.
    • a new onWaitTimeout option has been added, to allow defining a default behavior when a waitFor* function times out.
    • Casper.resourceExists() and related functions now checks for non HTTP-404 received responses.
    • fixed #167 - fixed opening truncated/uncomplete root urls may give erroneous HTTP statuses
    • closes #205 - debugHTML() can have a selector passed; added getHTML()
    • closes #230 - added ClientUtils.getElementsBound() and Casper.getElementsBound()
    • fixed #235 - updated Casper.evaluate() to use phantomjs >= 1.6 native one. As a consequence, the injector module is marked as deprecated.
    • fixed #250 - prevent self tests to be run using the standard casper test command
    • fixed #254 - fix up one use of qsa, hit when filling forms with missing elements
    • fixed edge case when current document url couldn't be properly decoded
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC2(Jul 13, 2013)

    2012-10-01, v1.0.0-RC2

    Important Changes & Caveats

    • PhantomJS 1.6 is now the minimal requirement, PhantomJS 1.7 is supported.
    • CasperJS continues to ship with its own implementation of CommonJS' module pattern, due to the way it has to work to offer its own executable. While the implementations are nearly the same, 100% compatibility is not guaranteed.

    Bugfixes & enhancements

    • fixed #119 - Casper.currentHTTPStatus now defaults to null when resource are loaded using the file:// protocol
    • fixed #130 - added a --no-colors option to the casper test command to skip output coloration
    • fixed #153 - erroneous mouse event results when event.preventDefault() was used.
    • fixed #164 - ability to force CLI parameters as strings (see related documentation).
    • fixed #178 - added Casper.getPageContent() to access raw page body contents on non-html received content-types.
    • fixed #180 - CasperJS tests are now run against a local HTTP test server. A new casper selftest command has been added as well.
    • fixed #189 - fixed invalid XML due to message colorization
    • fixed #197 & #240 - Added new tester methods:
    • fixed #202 - Fix test status timeouts when running multiple suites
    • fixed #204 - Fix for when the url is changed via javascript
    • fixed #210 - Changed escape to encodeURIComponent for downloading binaries via POST
    • fixed #216 - Change clientutils to be able to set a global scope
    • fixed #219 - ease chaining of run() calls (more explanations)
    • fixed #222 & #211 - Change mouse event to include an X + Y value for click position
    • fixed #231 - added --pre and --post options to the casperjs test command to load test files before and after the execution of testsuite
    • fixed #232 - symlink resolution in the ruby version of the casperjs executable
    • fixed #236 - fixed Casper.exit returned this after calling phantom.exit() which may caused PhantomJS to hang
    • fixed #252 - better form.fill() error handling
    • added ClientUtils.getDocumentHeight()
    • added toString() and status() methods to Casper prototype.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC1(Jul 13, 2013)

    2012-06-26, v1.0.0-RC1

    PhantomJS 1.5 & 1.6

    PhantomJS >= 1.6 supported features

    • added support of custom headers sending in outgoing request - refs #137)
    • added support for prompt() and confirm() - closes #125
    • fixed #157 - added support for PhantomJS 1.6 WebPage#zoomFactor
    • added url.changed & navigation.requested events - refs #151
    Source code(tar.gz)
    Source code(zip)
  • 0.6.10(Jul 13, 2013)

    2012-06-04, v0.6.10

    • fixed #73 - Casper.download() not working correctly with binaries
    • fixed #129 - Can't put // comments in evaluate() function
    • closed #130 - Added a Dummy colorizer class, in order to disable colors in console output
    • fixed #133 - updated and fixed documentation about extensibility
    • added Casper.clickLabel() for clicking on an element found by its innerText content

    As a side note, the official website monolithic page has been split across several ones: http://casperjs.org/

    Source code(tar.gz)
    Source code(zip)
  • 0.6.9(Jul 13, 2013)

    2012-05-29, v0.6.9

    • BC BREAK: PhantomJS 1.5 is now the minimal PhantomJS version supported.
    • fixed #114 - ensured client-side utils are injected before any evaluate() call
    • merged #89 - Support for more mouse events (@nrabinowitz)
    • added a new error event, better error reporting
    • fixed #117 - fill() coulnd't submit() a form with a submit input named submit
    • merged #122 - allow downloads to be triggered by more than just GET requests
    • closed #57 - added context to emitted test events + complete assertion framework refactor
    • fixed loaded resources array is now reset adequately reference discussion
    • fixed incomplete error message logged when passed an erroneous selector (xpath and css)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.8(Jul 13, 2013)

  • 0.6.7(Jul 13, 2013)

    2012-05-12, v0.6.7

    • fixes #107: client utils were possibly not yet being injected and available when calling Capser.base64encode() from some events
    • merged PR #96: make python launcher use os.execvp() instead of subprocess.Popen() (@jart):

      This patch fixes a bug where casperjs' python launcher process won't pass along kill signals to the phantomjs subprocess. This patch works by using an exec system call which causes the phantomjs subprocess to completely replace the casperjs parent process (while maintaining the same pid). This patch also has the added benefit of saving 10 megs or so of memory because the python process is discarded.

    • fixes #109 - CLI args containing = (equals sign) were not parsed properly
    • fixes #100 & #110 - googlepagination sample was broken
    • merged #103 - added Tester.assertNotEquals method (@juliangruber)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.6(Jul 13, 2013)

    2012-04-27, v0.6.6

    • BC BREAK:: moved the page.initialized event to where it should have always been, and is now using native phantomjs onInitialized event
    • fixed #95 - Tester.assertSelectorExists was broken
    Source code(tar.gz)
    Source code(zip)
  • 0.6.5(Jul 13, 2013)

    2012-03-28, v0.6.5

    • BC BREAK: reverted 8347278 (refs #34 and added a new clear() method to close a page You now have to call casper.clear() if you want to stop javascript execution within the remote DOM environment.
    • BC BREAK: removed fallbackToHref option handling in ClientUtils.click() (refs #63)
    • tester.findTestFiles() now returns results in predictable order
    • added --log-level and --direct options to casper test command
    • fixed 0.6.4 version number in bootstrap.js
    • centralized version number to package.json
    • ensured compatibility with PhantomJS 1.5
    Source code(tar.gz)
    Source code(zip)
Owner
CasperJS
CasperJS
A simple and stable cross-browser testing tool. 简单稳定的跨浏览器测试工具。

totoro A simple and stable cross-browser testing tool. Latest stable version: v2.0 Change Log 中文版使用文档 0. Features Run in real browsers Support all tes

totoro 568 Dec 21, 2022
End-to-end testing framework written in Node.js and using the Webdriver API

Nightwatch.js Homepage | Getting Started | Developer Guide | API Reference | About Automated end-to-end testing framework powered by Node.js and using

Nightwatch.js 11.3k Jan 7, 2023
Insanely fast, full-stack, headless browser testing using node.js

Zombie.js Insanely fast, headless full-stack testing using Node.js The Bite If you're going to write an insanely fast, headless browser, how can you n

Assaf Arkin 5.6k Dec 22, 2022
A next-generation code testing stack for JavaScript.

Intern Software testing for humans ⚠️ This documentation is for the development version of Intern. For the current release version, go here. Intern is

Intern: next-gen JavaScript testing 4.4k Jan 7, 2023
A node.js library for testing modern web applications

Taiko Docs | API reference A Node.js library for testing modern web applications What’s Taiko? Taiko is a free and open source browser automation tool

Gauge 3.2k Dec 30, 2022
Next-gen browser and mobile automation test framework for Node.js

Next-gen browser and mobile automation test framework for Node.js. Homepage | Developer Guide | API Reference | Contribute | Changelog | Roadmap Webdr

WebdriverIO 7.9k Jan 3, 2023
No longer actively maintained.

Vide No longer actively maintained. I am not interested to maintain jQuery plugins anymore. If you have some fixes, feel free to make PR. Easy as hell

Ilya Caulfield 3.3k Dec 20, 2022
No longer actively maintained.

Remodal No longer actively maintained. I am not interested to maintain jQuery plugins anymore. If you have some fixes, feel free to make PR. Responsiv

Ilya Caulfield 2.8k Dec 11, 2022
Easy-to-use , actively maintained discord bot written in dJS V13 with customizable features

Multi-purpose discord bot Found a bug? Notes There are some modules missing, you can still start the bot but there are some things within the source t

locus 7 Nov 28, 2022
A JSON polyfill. No longer maintained.

?? Unmaintained ?? JSON 3 is **deprecated** and **no longer maintained**. Please don't use it in new projects, and migrate existing projects to use th

BestieJS Modules 1k Dec 24, 2022
⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper

Cropper A simple jQuery image cropping plugin. As of v4.0.0, the core code of Cropper is replaced with Cropper.js. Demo Cropper.js - JavaScript image

Fengyuan Chen 7.8k Dec 27, 2022
No longer maintained, superseded by JS Cookie:

IMPORTANT! This project was moved to https://github.com/js-cookie/js-cookie, check the discussion. New issues should be opened at https://github.com/j

Klaus Hartl 8.6k Jan 5, 2023
⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-viewer

Viewer A simple jQuery image viewing plugin. As of v1.0.0, the core code of Viewer is replaced with Viewer.js. Demo Viewer.js - JavaScript image viewe

Fengyuan Chen 1k Dec 19, 2022
A scriptable browser like PhantomJS, based on Firefox

SlimerJS http://slimerjs.org/ SlimerJS is a scriptable browser. It allows you to manipulate a web page with an external Javascript script: opening a w

Laurent Jouanneau 3k Dec 31, 2022
Navigation-Menu-Javascript - A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked.

Navigation-Menu-Javascript A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked. Desktop view Mobile v

Ellis 2 Feb 16, 2021
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

Live Demo · Twitter A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Pris

Remix Stacks 18 Oct 31, 2022
A Mattermost Plugin which actively listens (and prohibits) for language with racist, ableist, sexist, or other exclusionary histories

Mattermost Gender Inclusive Language Plugin The gender-inclusive-language is a Mattermost Plugin which actively listens (and prohibits) for language w

Ademílson F. Tonato 2 Jun 22, 2022