Skip to content

Enable headless testing through casperjs. #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/data/MapfishPrintProvider.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
t.plan(2);

var getAbsoluteUrl = GeoExt.data.MapfishPrintProvider.prototype.getAbsoluteUrl;
var baseUrl = parent.location.href.substr(0, parent.location.href.indexOf("/tests/run-tests.html"));
var baseUrl = location.href.substr(0, location.href.indexOf("/tests/data/MapfishPrintProvider.html"));
t.eq(getAbsoluteUrl("/foo/bar.html"), location.protocol + "//" + location.host + "/foo/bar.html", "Relative url converted to absolute url correctly.");
t.eq(getAbsoluteUrl("../../bar.html"), baseUrl + "/bar.html", "Relative url with relative path converted to absolute url correctly.");
}
Expand Down
7 changes: 7 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/*.xml
/*.png
/docs/*.js
/docs/*.xml
/docs/_build
/tmp
Empty file.
10 changes: 10 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/.jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docs
modules/vendors
modules/events.js
modules/querystring.js
samples/**
tests/clitests/**
tests/testdir/**
tmp
./*.js
./phantomjs*/*
25 changes: 25 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"asi": true,
"browser": true,
"debug": true,
"devel": true,
"eqeqeq": true,
"evil": true,
"maxparams": 5,
"maxdepth": 3,
"maxstatements": 15,
"maxcomplexity": 7,
"proto": true,
"regexdash": true,
"strict": true,
"sub": true,
"trailing": true,
"undef": true,

"predef" : [
"exports",
"phantom",
"window",
"require"
]
}
35 changes: 35 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
branches:
only:
- "master"

before_install:
- echo "installing PhantomJS 1.8.2"
- wget http://phantomjs.googlecode.com/files/phantomjs-1.8.2-linux-x86_64.tar.bz2
- tar -xvf phantomjs-1.8.2-linux-x86_64.tar.bz2
- sudo mv phantomjs-1.8.2-linux-x86_64/bin/phantomjs bin/phantomjs182
- ls -la bin/phantomjs182
- bin/phantomjs182 --version
- echo "installing PhantomJS 1.9.0"
- wget http://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
- tar -xvf phantomjs-1.9.0-linux-x86_64.tar.bz2
- sudo mv phantomjs-1.9.0-linux-x86_64/bin/phantomjs bin/phantomjs190
- bin/phantomjs190 --version
- ls -la bin/phantomjs190

before_script:
- "npm install -g [email protected]"
- bin/phantomjs182 --version
- bin/phantomjs190 --version

script:
- make test

env:
matrix:
- PHANTOMJS_EXECUTABLE="bin/phantomjs182 --local-to-remote-url-access=yes --ignore-ssl-errors=yes"
- PHANTOMJS_EXECUTABLE="bin/phantomjs190 --local-to-remote-url-access=yes --ignore-ssl-errors=yes"

notifications:
irc:
channels:
- "irc.freenode.org#casperjs"
1 change: 1 addition & 0 deletions tests/headless/casperjs-1.1-beta.1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[This file has moved to Github](https://github.com/n1k0/casperjs/releases)
93 changes: 93 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Contribution Guide

*Note: this guide has been heavily inspired by [PhantomJS' one](https://github.com/ariya/phantomjs/blob/master/CONTRIBUTING.md).*

**This page describes how to contribute changes to the [CasperJS](http://casperjs.org/) project.**

Please do **not** create a pull request without reading this guide first. Failure to do so may result in the **rejection** of the pull request.

## For The Impatients

**Work on a feature branch**.
If your changes need to be modified due to some reviews, it is less clutter to tweak an isolated feature branch and push it again.

**Create a ticket in the [issue tracker](https://github.com/n1k0/casperjs/issues/)**.
This serves as a placeholder for important feedback, review, or any future updates. **Please ensure searching the bugtracker for an already opened issue matching your case before filing a new issue.**

In the commit message(s):

* **Keep the first line short**. Write additional paragraphs if necessary.
* **Reference an opened issue**, by referencing the issue ID prefixed by a `#` and the keyword `refs`, eg. `refs #123`

Sample commit message:

> refs #123 - fixed error message formatting
>
> (optional: a short explanation of what the patch actually does)

**Run tests**

Run CasperJS' test suite to see you didn't break something:

$ casperjs selftest

The result status bar **must be green** before sending your PR.

## Communicate

**Improvement and feature request**. If you have an improvement idea, please send an email to the [mailing list](http://groups.google.com/group/casperjs) (preferable than contacting the developers directly) so that other people can give their insights and opinions. This is also important to avoid duplicate work.

**Help request**. If you're stuck using CasperJS and don't understand how to achieve something, please [ask on the mailing-list](https://groups.google.com/forum/#!forum/casperjs) first. Please don't ask for all the kind people to write your scripts for you.

**Ensure the issue is related to CasperJS**. Please try to reproduce the issue using plain PhantomJS. If it works with the native PhantomJS API but doesn't with CasperJS, then the issue is probably valid. In the opposite case, please file an issue on [PhantomJS issue tracker](http://code.google.com/p/phantomjs/issues/list).

**Extending with new API**. Whenever you want to introduce a new API, please send an email to the mailing list along with the link to the issue if any. It may require few iterations to agree on the final API and hence it is important to engage all interested parties as early as possible.

## Get Ready

### Use Feature Branch

To isolate your change, please avoid working on the master branch. Instead, work on a *feature branch* (often also known as *topic branch*). You can create a new branch (example here crash-fix) off the master branch by using:

git checkout -b crash-fix master

Refer to your favorite Git tutorial/book for further detailed help.

Some good practices for the feature branch:

* Give it a meaningful name instead of, e.g. `prevent-zero-divide` instead of just `fix`
* Make *granular* and *atomic* commits, e.g. do not mix a typo fix with some major refactoring
* Keep one branch for one specific issue. If you need to work on other unrelated issues, create another branch.

### Write tests

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).

### Run tests!

This may sound obvious but **don't send pull requests which break the casperjs test suite**.

To see if your modifications broke the suite, just run:

$ casperjs selftest

### Write documentation

Do you appreciate the [CasperJS documentation](http://casperjs.org/)? I do too. As the documentation contents are managed and generated using Github, Markdown and CasperJS itself, take the time to read the [Documentation Contribution Guide](https://github.com/n1k0/casperjs/blob/gh-pages/README.md#casperjs-documentation) and write the documentation related to your PR whenever applicable.

**Note:** As the documentation is handled in a [dedicated separated `gh-pages` branch](https://github.com/n1k0/casperjs/tree/gh-pages), you'll have to send a dedicated PR for doc patches. I'm working on a more comfortable solution, but it's no easy task though.

## Review and Merge

When your branch is ready, send the pull request.

While it is not always the case, often it is necessary to improve parts of your code in the branch. This is the actual review process.

Here is a check list for the review:

* It does not break the test suite
* There is no typo
* The coding style follows the existing one
* There is a reasonable amount of comment
* The license header is intact
* All examples are still working
83 changes: 83 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# CasperJS contributors

You can check out the [contribution graphs on github](https://github.com/n1k0/casperjs/graphs/contributors).

```
$ git shortlog -s -n | cut -c8-
Nicolas Perriault
Laurent Jouanneau
oncletom
Brikou CARRE
hexid
Julien Muetton
hannyu
Chris Bosco
Matt Bowman
Shiryaev Andrey
Chris Lorenzo
Victor Yap
JF Paradis
Rob Barreca
nrabinowitz
pborreli
Darrell Hamilton
Tyler Ritchie
Oleg Pudeyev
renatodarrigo
Clochix
Luke Rodgers
Andrew Childs
reina.sweet
Solomon White
Dave Lee
Michael Geers
Julien Moulin
Philip Hansen
Donovan Hutchinson
Elmar Langholz
Reid Lynch
Reina Sweet
Sean Massa
Thomas Rosenau
Lee Byrd
V Sreekanth
Vladimir Chizhov
Jan Schaumann
Jason Funk
snkashis
Andrew de Andrade
Ben Johnson
Ben Lowery
Charlie Park
Chris Winters
Christophe Benz
Dmitry Menshikov
Harrison Reiser
Itamar Nabriski
Jan Pochyla
Jan-Martin Fruehwacht
Julian Gruber
Justin Marsan
Justin Slattery
Justine Tunney
KaroDidi
Leandro Boscariol
Maisons du monde
Marcel Duran
Mathieu Agopian
Mehdi Kabab
Mickaël Andrieu
Mikko Peltonen
Narno
Orchestrator81
Pascal Borreli
Rafael
Rafael Garcia
Raphaël Benitte
Rock Li
Tim Bunce
Tzvi Friedman
Yevgeny Smirnov
alfetopito
jean-philippe serafin
```
19 changes: 19 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2011-2012 Nicolas Perriault

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
17 changes: 17 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.PHONY: default test docs selftest clitest jshint

default: test

test: selftest clitest jshint

docs:
sphinx-build -b html ./docs docs/_build

selftest:
bin/casperjs selftest

clitest:
python tests/clitests/runtests.py

jshint:
jshint .
79 changes: 79 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# CasperJS

>**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.
>
>Use the [`1.0` branch](https://github.com/n1k0/casperjs/tree/1.0) if you want to keep in sync with the stable old version, or [use tagged versions](https://github.com/n1k0/casperjs/tags).
>
>Currently, available documentation is:
>
>- **hosted on [docs.casperjs.org](http://docs.casperjs.org/) for the development branch**
>- hosted on [casperjs.org](http://casperjs.org/) for the 1.0 branch
>
>[Travis-CI](http://travis-ci.org/n1k0/casperjs) build status:
>
>- ![Build Status](https://travis-ci.org/n1k0/casperjs.png?branch=master) `master` branch
>- 1.0 tests unfortunately have to be run manually using the `casperjs selftest` command

CasperJS is a navigation scripting & testing utility for [PhantomJS](http://www.phantomjs.org/)
and [SlimerJS](http://slimerjs.org/). It eases the process of defining a full navigation
scenario and provides useful high-level functions, methods & syntaxic sugar for doing common
tasks such as:

- defining & ordering [navigation steps](http://casperjs.org/quickstart.html)
- [filling forms](http://casperjs.org/api.html#casper.fill)
- [clicking links](http://casperjs.org/api.html#casper.click)
- [capturing screenshots](http://casperjs.org/api.html#casper.captureSelector) of a page (or an area)
- [making assertions on remote DOM](http://casperjs.org/api.html#tester)
- [logging](http://casperjs.org/logging.html) & [events](http://casperjs.org/events-filters.html)
- [downloading base64](http://casperjs.org/api.html#casper.download) encoded resources, even binary ones
- catching errors and react accordingly
- writing [functional test suites](http://casperjs.org/testing.html), exporting results as JUnit XML (xUnit)

Browse the [sample examples repository](https://github.com/n1k0/casperjs/tree/master/samples).
Don't hesitate to pull request for any cool example of yours as well!

**Read the [full documentation](http://casperjs.org/) on casperjs dedicated website.**

Subscribe to the [project mailing-list](https://groups.google.com/forum/#!forum/casperjs)

Follow the CasperJS project [on twitter](https://twitter.com/casperjs_org) and [Google+](https://plus.google.com/b/106641872690063476159/).

## Show me some code!

Sample test to see if some dropdown can be opened:

```javascript
casper.test.begin('a twitter bootsrap dropdown can be opened', 2, function(test) {
casper.start('http://twitter.github.com/bootstrap/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:

![](http://cl.ly/image/271e2i403A0F/Capture%20d%E2%80%99%C3%A9cran%202013-01-20%20%C3%A0%2009.26.15.png)

##Support

If you're having problems with using the project, use the support forum at CodersClan.

<a href="http://codersclan.net/forum/index.php?repo_id=32"><img src="http://www.codersclan.net/graphics/getSupport_blue_big.png" width="160"></a>

## Contributing

### Contributing code

Please read the [CONTRIBUTING.md](https://github.com/n1k0/casperjs/blob/master/CONTRIBUTING.md) file contents.

### Contributing documentation

CasperJS's documentation is written using the [Markdown format](http://daringfireball.net/projects/markdown/), and hosted on Github thanks to the [Github Pages Feature](http://pages.github.com/).

To view the source files on github, head to [the gh-pages branch](https://github.com/n1k0/casperjs/tree/gh-pages), and check the [documentation's README](https://github.com/n1k0/casperjs/tree/gh-pages#readme) for further instructions.
5 changes: 5 additions & 0 deletions tests/headless/casperjs-1.1-beta.1/batchbin/casperjs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF
set CASPER_PATH=%~dp0..
set CASPER_BIN=%CASPER_PATH%\bin\
set ARGV=%*
call phantomjs "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV%
Loading