Casperjs Practical Notes (1)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.