Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit eae104b

Browse files
committed
created basic index
1 parent 7973cf3 commit eae104b

18 files changed

+539
-198
lines changed

modules/cli.rst renamed to cli.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
.. _cli_module:
1+
.. _cli:
22

3-
==================
4-
The ``cli`` module
5-
==================
3+
.. index:: Command line, CLI, PhantomJS, Shell, arguments, options
4+
5+
======================
6+
Using the command line
7+
======================
68

79
CasperJS ships with a built-in command line parser on top of PhantomJS' one, located in the ``cli`` module; it exposes passed arguments as **positional ones** and **named options**
810

@@ -85,10 +87,15 @@ Last but not least, you can still use all PhantomJS standard CLI options as you
8587
Hint To remember what the native phantomjs available cli options are,
8688
run the ``phantomjs --help`` command.
8789

90+
91+
.. index:: Raw values
92+
8893
Raw parameter values
8994
--------------------
9095

91-
Added in 1.0 By default, the cli object will process every passed argument & cast them to the appropriate detected type; example script::
96+
.. versionadded:: 1.0
97+
98+
By default, the cli object will process every passed argument & cast them to the appropriate detected type; example script::
9299

93100
var casper = require('casper').create();
94101
var utils = require('utils');

debugging.rst

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
.. _debugging:
22

3+
.. index:: Bugs, Debugging
4+
35
=========
46
Debugging
57
=========
68

79
Here's are a few tips for debugging your casper scripts.
810

9-
Use the verbose mode
10-
--------------------
1111

12-
By default & by design, a ``Casper`` instance won't print anything to the console. This can be very limitating & frustrating when creating or debugging scripts, so a good practice is to always start coding a scrip using these settings::
12+
Use the :index:`verbose` mode
13+
-----------------------------
14+
15+
By default & by design, a ``Casper`` instance won't print anything to the console. This can be very limitating & frustrating when creating or debugging scripts, so a good practice is to always start coding a script using these :index:`settings`::
1316

1417
var casper = require('casper').create({
1518
verbose: true,
@@ -22,8 +25,9 @@ The ``verbose`` setting will tell Casper to write every logged message at the ``
2225

2326
Output will then be pretty verbose, and will potentially display sensitive informations onto the console. **Use with care on production.**
2427

25-
Hook in the deep using events
26-
-----------------------------
28+
29+
Hook in the deep using :index:`events`
30+
--------------------------------------
2731

2832
:doc:`Events <events-filters>` are a very powerful features of CasperJS, and you should probably give it a look if you haven't already.
2933

@@ -43,11 +47,31 @@ Listening to an event is dead easy::
4347

4448
Ensure to check the :ref:`full list <events_list>` of all the other available events.
4549

50+
51+
.. _debugging_dump:
52+
53+
Dump serialized values to the console
54+
-------------------------------------
55+
56+
Sometimes it's helpful to inspect a variable, especially Object contents. The :ref:`utils_dump() <utils_dump>` function can achieve just that::
57+
58+
require('utils').dump({
59+
foo: {
60+
bar: 42
61+
},
62+
});
63+
64+
.. note::
65+
66+
:ref:`utils_dump() <utils_dump>` won't be able to serialize function nor complex cyclic structures though.
67+
68+
4669
Localize yourself in modules
4770
----------------------------
4871

4972
If you're creating Casper modules, a cool thing to know is that there's a special built-in variable available in every module, ``__file__``, which contains the absolute path to current javascript file (the module file).
5073

74+
5175
Name your closures
5276
------------------
5377

@@ -73,6 +97,6 @@ Probably one of the most easy but effective best practice, always name your clos
7397
});
7498
});
7599

76-
That way, everytime one is failing, its name will be printed out in the *stack trace*, **so you can more easily locate it within your code**.
100+
That way, everytime one is failing, its name will be printed out in the :index:`stack trace`, **so you can more easily locate it within your code**.
77101

78102
Note that this one also applies for all your other Javascript works, of course ;)

events-filters.rst

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Events & filters
66
CasperJS provides an `event handler <#events>`_ very similar to the `nodejs <http://nodejs.org>`_' `one <https://github.com/joyent/node/blob/master/lib/events.js>`_; actually it borrows most of its codebase. CasperJS also adds `filters <#filters>`_, which are basically ways to alter values asynchronously.
77

88

9+
.. index:: ! events
10+
911
Events
1012
------
1113

@@ -20,9 +22,7 @@ Using events is pretty much straightforward if you're a node developer, or if yo
2022
Emitting you own events
2123
+++++++++++++++++++++++
2224

23-
Of course you can emit your own events, using the ``Casper.emit()`` method:
24-
25-
::
25+
Of course you can emit your own events, using the ``Casper.emit()`` method::
2626

2727
var casper = require('casper').create();
2828

@@ -48,15 +48,16 @@ Events reference
4848

4949
**Arguments:** ``None``
5050

51-
Emitted when the embedded browser is asked to go back a step in its
52-
history.
51+
Emitted when the embedded browser is asked to go back a step in its history.
5352

5453
``capture.saved``
5554
~~~~~~~~~~~~~~~~~
5655

5756
**Arguments:** ``targetFile``
5857

59-
Emitted when a screenshot image has been captured.
58+
Emitted when a :index:`screenshot` image has been captured.
59+
60+
.. index:: click
6061

6162
``click``
6263
~~~~~~~~~
@@ -72,13 +73,17 @@ Emitted when the ``Casper.click()`` method has been called.
7273

7374
Emitted when the ``Casper.die()`` method has been called.
7475

76+
.. index:: download
77+
7578
``downloaded.file``
7679
~~~~~~~~~~~~~~~~~~~
7780

7881
**Arguments:** ``targetPath``
7982

8083
Emitted when a file has been downloaded by :ref:`Casper.download() <casper_download>`; ``target`` will contain the path to the downloaded file.
8184

85+
.. index:: error
86+
8287
``error``
8388
~~~~~~~~~
8489

@@ -88,13 +93,17 @@ Emitted when a file has been downloaded by :ref:`Casper.download() <casper_downl
8893

8994
Emitted when an error hasn't been caught. Do basically what PhantomJS' ``onError()`` native handler does.
9095

96+
.. index:: exit
97+
9198
``exit``
9299
~~~~~~~~
93100

94101
**Arguments:** ``status``
95102

96103
Emitted when the ``Casper.exit()`` method has been called.
97104

105+
.. index:: fill
106+
98107
``fill``
99108
~~~~~~~~
100109

@@ -109,21 +118,23 @@ Emitted when a form is filled using the ``Casper.fill()`` method.
109118

110119
Emitted when the embedded browser is asked to go forward a step in its history.
111120

121+
.. index:: auth
122+
112123
``http.auth``
113124
~~~~~~~~~~~~~
114125

115126
**Arguments:** ``username, password``
116127

117128
Emitted when http authentication parameters are set.
118129

130+
.. index:: HTTP
131+
119132
``http.status.[code]``
120133
~~~~~~~~~~~~~~~~~~~~~~
121134

122135
**Arguments:** ``resource``
123136

124-
Emitted when any given HTTP reponse is received with the status code specified by ``[code]``, eg.:
125-
126-
::
137+
Emitted when any given HTTP reponse is received with the status code specified by ``[code]``, eg.::
127138

128139
casper.on('http.status.404', function(resource) {
129140
casper.echo(resource.url + ' is 404');
@@ -150,14 +161,14 @@ Emitted when PhantomJS' ``WebPage.onLoadFinished`` event callback has been calle
150161

151162
Emitted when PhantomJS' ``WebPage.onLoadFinished`` event callback is called.
152163

164+
.. index:: log
165+
153166
``log``
154167
~~~~~~~
155168

156169
**Arguments:** ``entry``
157170

158-
Emitted when the ``Casper.log()`` method has been called. The ``entry`` parameter is an Object like this:
159-
160-
::
171+
Emitted when the ``Casper.log()`` method has been called. The ``entry`` parameter is an Object like this::
161172

162173
{
163174
level: "debug",
@@ -166,6 +177,8 @@ Emitted when the ``Casper.log()`` method has been called. The ``entry`` paramete
166177
date: "a javascript Date instance"
167178
}
168179

180+
..index:: click
181+
169182
``mouse.click``
170183
~~~~~~~~~~~~~~~
171184

@@ -203,14 +216,14 @@ Emitted when the mouse releases the left button over something or somewhere.
203216

204217
Emitted each time a navigation operation has been requested. Available navigation types are: ``LinkClicked``, ``FormSubmitted``, ``BackOrForward``, ``Reload``, ``FormResubmitted`` and ``Other``.
205218

219+
.. index:: HTTP
220+
206221
``open``
207222
~~~~~~~~
208223

209224
``location, settings``
210225

211-
Emitted when an HTTP request is sent. First callback arg is the location, second one is a request settings Object of the form:
212-
213-
::
226+
Emitted when an HTTP request is sent. First callback arg is the location, second one is a request settings Object of the form::
214227

215228
{
216229
method: "post",
@@ -229,9 +242,7 @@ Emitted when PhantomJS' ``WebPage`` object used by CasperJS has been created.
229242

230243
**Arguments:** ``message, trace``
231244

232-
Emitted when retrieved page leaved a Javascript error uncaught:
233-
234-
::
245+
Emitted when retrieved page leaved a Javascript error uncaught::
235246

236247
casper.on("page.error", function(msg, trace) {
237248
this.echo("Error: " + msg, "ERROR");
@@ -244,13 +255,17 @@ Emitted when retrieved page leaved a Javascript error uncaught:
244255

245256
Emitted when PhantomJS' ``WebPage`` object used by CasperJS has been initialized.
246257

258+
.. index:: HTTP
259+
247260
``page.resource.received``
248261
~~~~~~~~~~~~~~~~~~~~~~~~~~
249262

250263
**Arguments:** ``response``
251264

252265
Emitted when the HTTP response corresponding to current required url has been received.
253266

267+
.. index:: HTTP
268+
254269
``page.resource.requested``
255270
~~~~~~~~~~~~~~~~~~~~~~~~~~~
256271

@@ -391,6 +406,8 @@ Emitted when the execution time of the script has reached the ``Casper.options.t
391406

392407
Added in 1.0 Emitted each time the current page url changes.
393408

409+
.. index:: viewport
410+
394411
``viewport.changed``
395412
~~~~~~~~~~~~~~~~~~~~
396413

@@ -420,12 +437,12 @@ Emitted when a ``Casper.wait()`` operation starts.
420437
Emitted when the execution time of a ``Casper.wait*()`` operation has exceeded the value of ``Casper.options.stepTimeout``.
421438

422439

440+
.. index:: filters
441+
423442
Filters
424443
-------
425444

426-
Filters allow you to alter some values asynchronously. Sounds obscure? Let's take a simple example and imagine you would like to alter every single url opened by CasperJS to append a ``foo=42`` query string parameter:
427-
428-
::
445+
Filters allow you to alter some values asynchronously. Sounds obscure? Let's take a simple example and imagine you would like to alter every single url opened by CasperJS to append a ``foo=42`` query string parameter::
429446

430447
var casper = require('casper').create();
431448

@@ -440,6 +457,8 @@ Here'a the list of all available filters with their expected return value:
440457
Filters reference
441458
+++++++++++++++++
442459

460+
.. index:: screenshot
461+
443462
``capture.target_filename``
444463
~~~~~~~~~~~~~~~~~~~~~~~~~~~
445464

@@ -485,9 +504,7 @@ Allows to alter every url before it being opened.
485504

486505
.. versionadded:: 1.0
487506

488-
Allows to react on a javascript ``confirm()`` call:
489-
490-
::
507+
Allows to react on a javascript ``confirm()`` call::
491508

492509
casper.setFilter("page.confirm", function(msg) {
493510
return msg === "Do you like vbscript?" ? false : true;
@@ -502,9 +519,7 @@ Allows to react on a javascript ``confirm()`` call:
502519

503520
.. versionadded:: 1.0
504521

505-
Allows to react on a javascript ``prompt()`` call:
506-
507-
::
522+
Allows to react on a javascript ``prompt()`` call::
508523

509524
casper.setFilter("page.prompt", function(msg, value) {
510525
if (msg === "What's your name?") {

extending.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. _extending:
22

3+
.. index:: extending, inheritance, prototype
4+
35
=========
46
Extending
57
=========
@@ -92,7 +94,10 @@ But that's just plain old *monkey-patching* the ``casper`` object, and you may p
9294

9395
**Don't forget to call ``Casper``'s parent constructor!**
9496

95-
Note Of course this approach is bit more verbose than the easy *monkey-patching* one, so please ensure you're not just overengineering stuff by subclassing the ``Casper`` class.
97+
Of course this approach is bit more verbose than the easy *monkey-patching* one, so please ensure you're not just overengineering stuff by subclassing the ``Casper`` class.
98+
99+
100+
.. index:: coffeescript
96101

97102
Using CoffeeScript
98103
~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)