Casperjs:我的应用程序元素是通过ajax调用无法找到元素

时间:2015-09-29 09:05:13

标签: casperjs

我的html页面如下所示:

代码:

var utils = require('utils');
 var x = require("casper").selectXPath;

 var loginurl = 'http://************:3000/login';

 casper.test.begin('asserExists() tests',1,function(test){


   // print out all the messages in the headless browser context
  casper.on('remote.message', function(msg) {
this.echo('remote message caught: ' + msg);
 });

 // print out all the messages in the headless browser context
   casper.on("page.error", function(msg, trace) {
this.echo("Page Error: " + msg, "ERROR");
});


//start the url
casper.start(loginurl,function(){

  //this.evaluate(function () { jq = $.noConflict(true) } );
  //wait for some time

    casper.wait(30000, function() {
      this.echo("I've waited for a some time for the page to load.");
  });

  test.assertExists('form', 'form is found');

  this.capture('screen.png');

  this.waitForSelector('form', function(){
this.fill('form', {
'username': '********', 
'password': '**********!'}, true);

  });



 });

   });

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



<html lang="en">
<head>
    <meta charset="utf-8">
    <title>loki</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="loki - a network modeling and reporting toolkit">
    <meta name="author" content="*******">
    <link rel="icon" href="/assets/favicon.ico" type="image/x-icon" />
    <!-- Styles -->
    <link href="/css/app.min.css" rel="stylesheet" media="all">
</head>

<body class="site" data-spy="scroll" data-offset="0" data-target="#navbar-main">
    <div class="container-fluid site-main"> </div>

    <!-- Javascript
    Loaded last so page renders first...
    ================================================== -->
    <script src="**/js/app.min.js**"></script>

</body>

**strong text**/js/app.min.js this contains elements


     Output:`DNANJUND-M-H06L:Desktop ******$ casperjs test --verbose --log-          level=debug     
          NewSample.js 
               2015-09-30 14:45:15.994 phantomjs[93706:1845116] *** WARNING:         Method  
           userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. 
          It should not be used in new applications. Use convertRectToBacking: instead. 
       Test file: NewSample.js                                                         
      # asserExists() tests
       [info] [phantom] Starting...
       [info] [phantom] Running suite: 2 steps
     [debug] [phantom] opening url: http://***********:3000/login, HTTP GET
       [debug] [phantom] Navigation requested: url=http://******:3000/login,  type=Other,
      willNavigate=true, isMainFrame=true
      [debug] [phantom] url changed to "http://***********:3000/login"
        Page Error: TypeError: 'undefined' is not a function (evaluating 'h.bind(null,i)')
       [debug] [phantom] Successfully injected Casper client-side utilities
        [info] [phantom] Step anonymous 2/2 http://**************:3000/login (HTTP 200)
       FAIL form is found
    #    type: assertExists
    #    file: NewSample.js:30
     #    code: test.assertExists('form', 'form is found');
    #    subject: false
    #    selector: "form"
   [info] [phantom] Step anonymous 2/2: done in 12043ms.
    [info] [phantom] Step _step 3/3 http://********:3000/login (HTTP 200)
    [info] [phantom] Step _step 3/3: done in 12063ms.
    [info] [phantom] wait() finished waiting for 30000ms.
          I've waited for a some time for the page to load.
        [info] [phantom] Done 3 steps in 42072ms
      FAIL ReferenceError: Can't find variable: done
      #    type: uncaughtError
     #    file: NewSample.js:48
      #    error: Can't find variable: done
     #           ReferenceError: Can't find variable: done
    #               at NewSample.js:48
      #               at checkStep (/usr/local/Cellar/casperjs/1.1- beta3/libexec/modules/casper.js:408)
       #    stack: not provided
       FAIL 2 tests executed in 42.1s, 0 passed, 2 failed, 0 dubious, 0 skipped.       

        Details for the 2 failed tests:

    In NewSample.js:30
        asserExists() tests
       assertExists: form is found
      In NewSample.js:48
        asserExists() tests
        uncaughtError: ReferenceError: Can't find variable: done`

添加了脚本的输出和输入,没有捕获任何元素只有网址才能看到http 200我没看到任何点没有捕获任何元素。请帮助我这里

0 个答案:

没有答案