Phantomjs Casperjs将大型机切换到新选项卡

Phantomjs Casperjs将大型机切换到新选项卡,phantomjs,casperjs,Phantomjs,Casperjs,我正在使用casperjs浏览站点,但在登录过程中遇到问题: 在站点中,当您登录时,浏览器切换到一个新选项卡,登录表单重置为空白,我看到这个新选项卡包含导航调试中请求的数据,如下所示: [debug] [phantom] Navigation requested: url=www.thesite.com, type=FormSubmitted, willNavigate=true, isMainFrame=false 我注意到isMainFrame=false,并尝试使用一些方法(如switc

我正在使用casperjs浏览站点,但在登录过程中遇到问题:

在站点中,当您登录时,浏览器切换到一个新选项卡,登录表单重置为空白,我看到这个新选项卡包含导航调试中请求的数据,如下所示:

[debug] [phantom] Navigation requested: url=www.thesite.com, type=FormSubmitted, willNavigate=true, isMainFrame=false
我注意到isMainFrame=false,并尝试使用一些方法(如switchToChildFrame、casper.withFrame()或casper.withPopup())切换帧,但失败了

是否有任何方法可以检索该请求的内容并与之交互

到目前为止,我的代码是:

casper.start('www.thesite.com', function() {
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
this.wait(2000);
casper.withFrame('centro', function() {
    this.fillSelectors('form[name="teclado"]', {
        'input[name="IdGroup"]': 'AAA',
        'input[name="IdUser"]': 'BBB',
        'input[name="password"]': 'CCC'
    }, false);
    //this capture retrieves the form filled with my data
    this.capture('../../../1.png');
    this.click("a[onclick='enviar();return true;']");
    });
});
casper.withFrame( 0, function(){
    //2.png is getting the form with blank fields
    this.capture('../../../2.png');
});
提前谢谢。

好的,我解决了我的问题

问题是我写的弹出代码很糟糕

我编写了正则表达式来匹配弹出式url,这一点过于严格,因为我将大部分url放在了预期的位置:

casper.withPopup(/Estatico\/BEComponentesGeneralesAccesoSEI\/Html\/login.htm/, function() {
这对我来说没问题:

casper.withPopup(/true$/, function() {
    this.capture('../../../2.png');
});