CasperJS支持重定向URL

时间:2014-04-16 12:55:32

标签: web phantomjs casperjs

我想知道在使用casperjs时我们如何在URL之间切换:例如,我有

    casper.test.begin('Story', function suite(test) {
    casper.start("http://localhost:8000/", casper.entryPointOne);
    // POINT - P

    casper.run(function() {
        test.done();
    });

});

现在如果在POINT-P(在上面的代码中),我想访问完全不同的网址:例如我想访问www.gooogle.com,是否可能?

我需要这个来测试一个场景,我们访问*设置'页面,保存新设置,获得新的UrL(比如谷歌),然后使用这些设置。

问题在于保存设置后,我开始使用默认设置的新测试,不使用新设置。

知道怎么做吗?

1 个答案:

答案 0 :(得分:1)

使用thenOpen打开后续网址。

 casper.test.begin('Story', function suite(test) {
    casper.start("http://localhost:8000/", casper.entryPointOne);
    // POINT - P

casper.thenOpen('http://www.noobmovies.com')

    casper.run(function() {
        test.done();
    });

});