2

So i just want to open a webpage , but a big part of it are scripts read by the browser...

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv='Content-type' content='text/html; charset=utf-8'>
    <title>MyAccount</title>
    <link rel="stylesheet" href="/vendor.css" />
    <link rel="stylesheet" href="/app.css" />
  </head>
  <body>

    <div id="container">
    // Here is the rest generated by the script. On chrome i can see it easily (inspect element)
    </div>

    <script type="text/javascript">
        window.myAccountUrl = "http://urlsample";
    </script>
    <script type="text/javascript" src="/vendor.js"></script>
    <script type="text/javascript" src="/app.js"></script>
    <script type="text/javascript" src="/init.js"></script>

  </body>
</html>

but with casper nothing appear in it. I use this settings:

pageSettings: {
        loadImages:  true,    
        loadPlugins: true,
        javascriptEnabled: true,
        localToRemoteUrlAccessEnabled: true,
        XSSAuditingEnabled: true
    }

And i render the html like that:

var js = this.evaluate(function() {
    return document; 
});
this.echo(js.all[0].outerHTML); 

If anyone can help me, he's welcome. :)

Bertos
  • 63
  • 1
  • 8
  • 2
    Please register to the [`remote.message`](http://docs.casperjs.org/en/latest/events-filters.html#remote-message) and [`page.error`](http://docs.casperjs.org/en/latest/events-filters.html#page-error) events. Maybe there are errors. If bind is an issue, you need a [shim](https://github.com/ariya/phantomjs/issues/10522#issuecomment-39248521). Maybe try to run CasperJS with `--web-security=false`. – Artjom B. Sep 17 '14 at 15:06
  • Ok i will try this. But i would like to remind that casperjs do render html, only without what's inside the container div. – Bertos Sep 18 '14 at 09:48
  • Error: TypeError: 'undefined' is not a function (evaluating 'RegExp.prototype.test.bind( /^(data|aria)-[a-z_][a-z\d_.\-]*$/ )') Error: ReferenceError: Can't find variable: Ux So i get some errors, thx! i will try to see what's wrong. – Bertos Sep 18 '14 at 10:04
  • possible duplicate of [CasperJS bind issue](http://stackoverflow.com/questions/25359247/casperjs-bind-issue) – Artjom B. Sep 18 '14 at 10:08
  • 1
    Thx! that was it. I just learned that the site use reactJS, so that's why i had problems. – Bertos Sep 19 '14 at 12:05

0 Answers0