PDA

View Full Version : CasperJS to test ExtJS Applications



charles.bourasseau
12 Jul 2012, 12:21 AM
I would like to use CasperJS to test and take documentation screenshot of a ExtJS Application.

The Probelm is that click event from CasperJS will fire twice in ExtJS, it's very strange.

I made a simple jsFiddle: http://jsfiddle.net/charlesbourasseau/fEDCu/
When you click on the button it executes console.log('Click!');
Pretty simple.

I make the same without ExtJS: http://jsfiddle.net/charlesbourasseau/MmCuG/

Now the CasperJS script:



url = 'http://fiddle.jshell.net/charlesbourasseau/fEDCu/show/'

casper.start url, ->
@click 'button'

casper.run ->
@test.renderResults true


Output with ExtJS fiddle:

$ casperjs extjs-fiddle.coffee
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://fiddle.jshell.net/charlesbourasseau/fEDCu/show/, HTTP GET
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step 2/2 http://fiddle.jshell.net/charlesbourasseau/fEDCu/show/ (HTTP 200)
[debug] [phantom] Mouse event 'click' on selector: .x-btn
[info] [remote] Click!
[info] [remote] Click!
[info] [phantom] Step 2/2: done in 4506ms.
[info] [phantom] Done 2 steps in 4592ms
FAIL Looks like you didn't run any test.

Output with pure Javascript fiddle:

casperjs javascript-fiddle.coffee
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://jsfiddle.net/charlesbourasseau/MmCuG/show/, HTTP GET
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step 2/2 http://jsfiddle.net/charlesbourasseau/MmCuG/show/ (HTTP 200)
[debug] [phantom] Mouse event 'click' on selector: button
[info] [remote] Click!
[info] [phantom] Step 2/2: done in 1524ms.
[info] [phantom] Done 2 steps in 1619ms
FAIL Looks like you didn't run any test.


In ExtJS this line comes two times: [info] [remote] Click!, not in Javascript.

Any ideas ?

scottmartin
16 Jul 2012, 4:54 PM
I have not tried using CasperJS, so I am not sure what would be causing this. Have you tried contacting Casper to see if they have any suggestions?

You tried using a create by itself to see if it makes any difference to Casper?

Scott.

charles.bourasseau
17 Jul 2012, 2:13 AM
I created an Issue in CasperJS and it was actually a bug in CasperJS.
It's now fixed.

Solution is to take the master branch of git, the fix should come in the next version.

Thanks for helping.

CasperJS is very great to test ExtJS applications.