Q:

waitForPopup in CasperJS always gets "wait timeout"

In my page automation script, when I click a label link, a new window will be opened. The url of the link is generated by a complicated javascript. 
<a class="link_text" href="#" onclick="process('2c913f9e4c7314e1014c74a4a5e02573')">办理任务 </a>
after triggered the url becomes:
https://oa.phicomm.com/workflow/doJob.action?taskVo.processExecutionId=2c913f9e49d0d5280149d12fabd90dd0&taskVo.taskId=10851011
I try to use the API- casper.waitForPopup after I do the click action.
casper.waitForPopup(/.+/, function(){
    this.echo(this.getTitle());
}, null, 20000);

But it failed as wait timeout 20000ms expired. I also tried put the urlstring as the parameter:
casper.waitForPopup(/oa.phicomm.com\/workflow\/doJob\.action\?taskVo\.processExecutionId=2c913f9e49d0d5280149d12fabd90dd0&taskVo\.taskId=9100818/, function{
    this.echo(this.getTitle());
});

still timeout. I also capture the screenshot, clearly it's still in the previous page. I try the thenOpen method directly inputting the url. It works. But since I want to auto it, I can't know the url before I actual trigger the link. I am a newer to CasperJS, anyone knows how to solve this problem? Thanks.

A:

There was same issue with me i have resolve this problem by first selector exist or not
casper.[waitForSelector][1]('#example_id', function() {
    this.echo("yes");

});

If your selector exist then try this
casper.[waitForPopup][1](0, function() {
    this.echo('Popup');
});
casper.withPopup(0, function() {
    this.capture('screen.png');
});  

Read more about waitForPopup

