Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
521ddb10
...
521ddb104d3a3b9f011ff8385dcf3bc61b217c2d
authored
2013-10-20 10:42:20 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated docs for resourceExists and waitForResource
1 parent
06646b11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
docs/modules/casper.rst
modules/casper.js
docs/modules/casper.rst
View file @
521ddb1
...
...
@@ -1382,9 +1382,9 @@ Repeats a navigation step a given number of times::
``resourceExists()``
-------------------------------------------------------------------------------
**Signature:** ``resourceExists(
Mixed
test)``
**Signature:** ``resourceExists(
String|Function|RegExp
test)``
Checks if a resource has been loaded. You can pass either a function
or a string
to perform the test::
Checks if a resource has been loaded. You can pass either a function
, a string or a ``RegExp`` instance
to perform the test::
casper.start('http://www.google.com/', function() {
if (this.resourceExists('logo3w.png')) {
...
...
@@ -2016,17 +2016,29 @@ The currently loaded popups are available in the ``Casper.popups`` array-like pr
``waitForResource()``
-------------------------------------------------------------------------------
**Signature:** ``waitForResource(
Function
testFx[, Function then, Function onTimeout, Number timeout])``
**Signature:** ``waitForResource(
String|Function|RegExp
testFx[, Function then, Function onTimeout, Number timeout])``
Wait until a resource that matches
the given ``testFx`` is loaded to process a next step. Uses `waitFor()`_::
Wait until a resource that matches
a resource matching constraints defined by ``testFx`` are satisfief to process a next step.
casper.start('http://foo.bar/');
The ``testFx`` argument can be either a string, a function or a ``RegExp`` instance::
casper.waitForResource("foobar.png", function() {
this.echo('foobar.png has been loaded.');
});
casper.run();
Using a regexp::
casper.waitForResource(/foo(bar|baz)\.png$/, function() {
this.echo('foobar.png or foobaz.png has been loaded.');
});
Using a function::
casper.waitForResource(function testResource(resource) {
return resource.url.indexOf("https") === 0;
}, function onReceived() {
this.echo('a secure resource has been loaded.');
});
.. _casper_waitforurl:
...
...
modules/casper.js
View file @
521ddb1
...
...
@@ -2084,11 +2084,11 @@ Casper.prototype.waitForPopup = function waitForPopup(urlPattern, then, onTimeou
/**
* Waits until a given resource is loaded
*
* @param String/Function test A function to test if the resource exists.
* A string will be matched against the resources url.
* @param Function then The next step to perform (optional)
* @param Function onTimeout A callback function to call on timeout (optional)
* @param Number timeout The max amount of time to wait, in milliseconds (optional)
* @param String/Function
/RegExp
test A function to test if the resource exists.
*
A string will be matched against the resources url.
* @param Function
then The next step to perform (optional)
* @param Function
onTimeout A callback function to call on timeout (optional)
* @param Number
timeout The max amount of time to wait, in milliseconds (optional)
* @return Casper
*/
Casper
.
prototype
.
waitForResource
=
function
waitForResource
(
test
,
then
,
onTimeout
,
timeout
)
{
...
...
Please
register
or
sign in
to post a comment