casperjs测试模式与自动化模式

时间:2015-03-19 23:17:52

标签: javascript casperjs

我是casperjs的新手,请原谅我的无知,但我很困惑为什么我的测试脚本在这种情况下的行为与我的自动化代码不同。

我有一个包含以下内容的测试脚本:

casper.test.begin('Are we online?', 7, function suite(test) {
    casper.start("http://www.google.com/", function() {
        test.assertTitle("Google", "Connected to google, internet connection probably ok");
    });

casper.thenOpen("https://example.com/", function() {

    this.fill('form#logonForm', {
        'Name':    'user',
        'Password':    'pass',
    }, true);
});

casper.thenOpen("https://example.com/page2", function() {
  this.capture('screenshot.png'); //I am  logged in fine
});

但是,如果我这样做,我会因为某些原因而退出登记:

casper.start("https://example.com/LoginPage", function() {
   this.fill('form#logonForm', {
        'Name':    'user',
        'Password':    'pass',
    }, true);
});

casper.thenOpen("https://example.com/page2", function() {
  this.capture('screenshot.png'); //this shows me I am NOT logged in, any idea why? 
});

这不是我已经提炼/简化的确切代码,希望我没有遗漏任何重要的区别,但据我所知,似乎是由于在测试套件中编写而不是?

0 个答案:

没有答案