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
09966609
...
09966609e28c89ceb94d118f72562a20c7d92368
authored
2012-01-08 18:59:08 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
closes #36 - Fixed args index (mouse.js) (@sasezaki)
1 parent
29521c0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
modules/mouse.js
tests/site/click.html
tests/suites/casper/click.js
modules/mouse.js
View file @
0996660
...
...
@@ -69,7 +69,7 @@ var Mouse = function(casper) {
break
;
case
2
:
// coordinates
if
(
!
utils
.
isNumber
(
args
[
1
])
||
!
utils
.
isNumber
(
args
[
2
]))
{
if
(
!
utils
.
isNumber
(
args
[
0
])
||
!
utils
.
isNumber
(
args
[
1
]))
{
throw
new
Error
(
'No valid coordinates passed'
);
}
casper
.
page
.
sendEvent
(
type
,
args
[
0
],
args
[
1
]);
...
...
tests/site/click.html
View file @
0996660
...
...
@@ -15,12 +15,16 @@
test1
:
false
,
test2
:
false
,
test3
:
false
,
test4
:
false
test4
:
false
,
test5
:
[]
};
document
.
querySelector
(
'#test4'
).
onclick
=
function
(
event
)
{
results
.
test4
=
true
;
event
.
preventDefault
();
};
window
.
onmousedown
=
function
(
e
)
{
results
.
test5
=
[
e
.
x
,
e
.
y
];
}
})(
window
);
</script>
</body>
...
...
tests/suites/casper/click.js
View file @
0996660
(
function
(
t
)
{
casper
.
start
(
'tests/site/index.html'
,
function
(
self
)
{
self
.
click
(
'a[href="test.html"]'
);
casper
.
start
(
'tests/site/index.html'
,
function
()
{
this
.
click
(
'a[href="test.html"]'
);
});
casper
.
then
(
function
(
self
)
{
casper
.
then
(
function
()
{
t
.
comment
(
'Casper.click()'
);
t
.
assertTitle
(
'CasperJS test target'
,
'Casper.click() can click on a link'
);
}).
thenClick
(
'a'
,
function
(
self
)
{
}).
thenClick
(
'a'
,
function
()
{
t
.
comment
(
'Casper.thenClick()'
);
t
.
assertTitle
(
'CasperJS test form'
,
'Casper.thenClick() can click on a link'
);
});
// onclick variants tests
casper
.
thenOpen
(
'tests/site/click.html'
,
function
(
self
)
{
casper
.
thenOpen
(
'tests/site/click.html'
,
function
()
{
t
.
comment
(
'CasperUtils.click()'
);
self
.
test
.
assert
(
self
.
click
(
'#test1'
),
'CasperUtils.click() can click an `href="javascript:` link'
);
self
.
test
.
assert
(
self
.
click
(
'#test2'
),
'CasperUtils.click() can click an `href="#"` link'
);
self
.
test
.
assert
(
self
.
click
(
'#test3'
),
'CasperUtils.click() can click an `onclick=".*; return false"` link'
);
self
.
test
.
assert
(
self
.
click
(
'#test4'
),
'CasperUtils.click() can click an unobstrusive js handled link'
);
var
results
=
self
.
getGlobal
(
'results'
);
self
.
test
.
assert
(
results
.
test1
,
'CasperUtils.click() has clicked an `href="javascript:` link'
);
self
.
test
.
assert
(
results
.
test2
,
'CasperUtils.click() has clicked an `href="#"` link'
);
self
.
test
.
assert
(
results
.
test3
,
'CasperUtils.click() has clicked an `onclick=".*; return false"` link'
);
self
.
test
.
assert
(
results
.
test4
,
'CasperUtils.click() has clicked an unobstrusive js handled link'
);
this
.
test
.
assert
(
this
.
click
(
'#test1'
),
'CasperUtils.click() can click an `href="javascript:` link'
);
this
.
test
.
assert
(
this
.
click
(
'#test2'
),
'CasperUtils.click() can click an `href="#"` link'
);
this
.
test
.
assert
(
this
.
click
(
'#test3'
),
'CasperUtils.click() can click an `onclick=".*; return false"` link'
);
this
.
test
.
assert
(
this
.
click
(
'#test4'
),
'CasperUtils.click() can click an unobstrusive js handled link'
);
var
results
=
this
.
getGlobal
(
'results'
);
this
.
test
.
assert
(
results
.
test1
,
'CasperUtils.click() has clicked an `href="javascript:` link'
);
this
.
test
.
assert
(
results
.
test2
,
'CasperUtils.click() has clicked an `href="#"` link'
);
this
.
test
.
assert
(
results
.
test3
,
'CasperUtils.click() has clicked an `onclick=".*; return false"` link'
);
this
.
test
.
assert
(
results
.
test4
,
'CasperUtils.click() has clicked an unobstrusive js handled link'
);
});
casper
.
run
(
function
(
self
)
{
// mouse.down
casper
.
then
(
function
()
{
t
.
comment
(
'Mouse.down()'
);
this
.
mouse
.
down
(
200
,
100
);
var
results
=
this
.
getGlobal
(
'results'
);
this
.
test
.
assertEquals
(
results
.
test5
,
[
200
,
100
],
'Mouse.down() has clicked the specified position'
);
});
casper
.
run
(
function
()
{
t
.
done
();
});
})(
casper
.
test
);
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment