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
96652285
...
966522850368cce95e34d0a64e22bf31acdab70d
authored
2012-10-27 10:20:02 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Tester.assertUrlMatch() now allows to search for a string
1 parent
7f1fcc8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
modules/tester.js
modules/tester.js
View file @
9665228
...
...
@@ -544,17 +544,27 @@ Tester.prototype.assertType = function assertType(subject, type, message) {
};
/**
* Asserts that a the current page url matches the provided RegExp
* pattern.
* Asserts that a the current page url matches a given pattern. A pattern may be
* either a RegExp object or a String. The method will test if the URL matches
* the pattern or contains the String.
*
* @param RegExp
pattern A RegExp object instance
* @param String
message
Test description
* @return Object An assertion result object
* @param RegExp
|String pattern The test pattern
* @param String
message
Test description
* @return Object
An assertion result object
*/
Tester
.
prototype
.
assertUrlMatch
=
Tester
.
prototype
.
assertUrlMatches
=
function
assertUrlMatch
(
pattern
,
message
)
{
"use strict"
;
var
currentUrl
=
this
.
casper
.
getCurrentUrl
();
return
this
.
assert
(
pattern
.
test
(
currentUrl
),
message
,
{
var
currentUrl
=
this
.
casper
.
getCurrentUrl
(),
patternType
=
utils
.
betterTypeOf
(
pattern
),
result
;
if
(
patternType
===
"regexp"
)
{
result
=
pattern
.
test
(
currentUrl
);
}
else
if
(
patternType
===
"string"
)
{
result
=
currentUrl
.
indexOf
(
pattern
)
!==
-
1
;
}
else
{
throw
new
CasperError
(
"assertUrlMatch() only accepts strings or regexps"
);
}
return
this
.
assert
(
result
,
message
,
{
type
:
"assertUrlMatch"
,
standard
:
"Current url matches the provided pattern"
,
values
:
{
...
...
Please
register
or
sign in
to post a comment