Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在一个文件中使用多个CasperJS模块?_Javascript_Node.js_Testing_Phantomjs_Casperjs - Fatal编程技术网

Javascript 如何在一个文件中使用多个CasperJS模块?

Javascript 如何在一个文件中使用多个CasperJS模块?,javascript,node.js,testing,phantomjs,casperjs,Javascript,Node.js,Testing,Phantomjs,Casperjs,我试图在一个文件中使用CasperJS和。我更喜欢简单地使用测试仪模块,但我需要自动单击。以下是我所拥有的: var config = { url: 'http://telluswho2.herokuapp.com/', }; casper.test.begin('Home page tests', 6, function suite(test) { casper.start(config.url, function() { test.assertTitleMatch(/T

我试图在一个文件中使用CasperJS和。我更喜欢简单地使用测试仪模块,但我需要自动单击。以下是我所拥有的:

var config = {
  url: 'http://telluswho2.herokuapp.com/',
};

casper.test.begin('Home page tests', 6, function suite(test) {

  casper.start(config.url, function() {

    test.assertTitleMatch(/TellUsWho2/, "TellUsWho2 homepage title is the one expected");
    test.assertExists('nav.navbar', 'Navbar Exists');
    test.assertElementCount('ul.navbar-nav', 1);
    test.assertSelectorHasText('a.navbar-brand', 'TellUsWho2');
    test.assertExists('h1.brand-heading', 'TellUsWho2 brand heading exists');
    test.assertVisible('footer');

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

});


casper.test.begin('Test if research page links to NJIT\'s homepage', 1, function suite(test) {

  casper.start(config.url, function() {

    this.click('a.btn-lg:nth-child(3)');
    test.comment('Clicking the login link...');

    casper.then(function () {
      test.assertTitleMatch(/New Jersey Institute of Technology/, "NJIT's homepage title is the one expected");
    });

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

});

我假设单击操作从未完成,因为我需要使用另一个模块。有什么想法吗?

为什么要在一个文件中使用多个casper实例?您希望解决的限制是什么?casper和casper.test应该一起使用。我看不出你的问题在哪里。请通过编辑您的问题详细描述。点击“a.btn-lg:nth-child3”;如果没有casper实例,它将无法工作,我不知道如何使用当前代码实现这一点@那么,您的意思是,当第一个test.begin被注释掉时,它就可以工作了?我不明白为什么会出现这种情况,因为第一个测试用例没有让您登录或对会话执行其他操作。