A problem with Casperjs's execution workflow (if you can, don't think this is a bug):
The pseudo code is as follows:
var casper = require ("Casper"). Create (); Casper.start ("http://xx.xx.com"); Casper.then ( function () { this. Echo ("AAAA"); This function () { this. Echo ("BBB"); }) this. Echo ("CCCC");}); Casper.run () { this. Echo ("...");};
The expected run result should be this:
AAAABBBCCCC ...
The actual running result is this:
AAAACCCCBBB ...
Casperjs itself is a PHANTOMJS test framework that uses the Python language package and has not seen its workflow implementation;
Methods Casper.then and methods casper.wait compose workflow logic, or workflow execution unit;
Other code is not treated as an execution unit, so it must be wrapped in casper.then or casper.wait.
Casper.wait is a series of APIs, in addition to Waitforselector, WaitFor, Waitwhileselector, waituntilvisible and so on;
The most used is this.waitforselector, which sets a timeout to wait for an element (Html element), and if so, what if it does.
So the code in the actual project is about the following:
This. Then (function(){ This. Echo ("Start ..."); This. WaitFor (/// ... ) This. Waitforselector (// ... )}) This. Then (function(){ This. Echo ("Start ..."); This. WaitFor (/// ... This. Waitforselector (// ... ) )})
(My small project is written by myself, a lot of things are in the groping stage)
I hope that experienced colleagues are not hesitate to enlighten!
Casperjs Practical Notes (1)