1

所以我正在用这段代码测试我的登录页面

describe('Testing the login page', function (t) {
    t.it('Should be possible to login', function (t) {
        t.chain(
            {
                waitForCQ : '>> textfield[itemId=login]'
            },
            {
                action  : 'type',
                target  : '>> textfield[itemId=login]',
                text    : 'accountname'
             },
            {
                action  : 'type',
                target  : '>> textfield[itemId=password]',
                text    : 'passwd[ENTER]'
             }
        )
    })
});

有了这个harness.start() conf:

harness.start(
  '010_sanity.t.js',
  {
    group   : 'Login/Logout',
    items   : [
      {
        enablePageRedirect : true,
        pageUrl : "https://mywebsite.com/Login",
        url     : "020_login.t.js"
      },
      {
        enablePageRedirect : true,
        pageUrl : "https://mywebsite.com/",
        url     : "021_logout.t.js"
      }
    ]
  },
  ...
);

我面临一个问题。即使将 enablePageRedirect 选项设置为 true,测试似乎也不会从第一页持续到下一页。相反,在午睡测试界面的日志记录区域(中一),我看到当页面发生变化时,测试从头开始重新启动。有一个永无止境的微调器。

如何使用 siesta 进行如此简单的跨页测试?该文档并没有真正帮助我:http ://www.bryntum.com/docs/siesta/#!/guide/cross_page_testing

提前致谢

4

1 回答 1

1

每个测试都应该从一个新页面开始并且是独立的,因此您的每个测试都需要从新登录应用程序开始。启用页面重定向只是意味着一旦发生登录,应用程序可以在到达下一页后继续进行测试。这是我们如何在测试中编写它的示例:

  test.chain(
    // Enter username
    {
      action: 'type',
      target: '#user_id',
      text: 'ACCOUNTNAMEHERE'
    },
    // Enter password
    {
      action: 'type',
      target: '#password',
      text: 'PASSWORDHERE'
    },
    // Set up detection of the page changing.
    // The trigger specifies what action will cause the
    // page to change. The timeout is the maximum length
    // to wait for the navigation to occur.
    {
      waitFor: 'PageLoad',
      timeout: 20000,
      trigger: {
        click: 'input[type=submit]'
      }
    }
  );
于 2017-03-02T17:25:00.773 回答