Zombie.js and the Google Maps API

I have a problem with the zombie.js testing base and the Google Maps API.

I have a simple zombie.js that loads the home page and tries to click the Sign In link. However, when I look at what returns to the HTML home page (from the point of view of the zombie.js browser object), I only see this in the body section:

<body>
  <script src="https://maps.gstatic.com/intl/en_us/mapfiles/api-3/9/12/main.js"     type="text/javascript"></script>
</body>

If I remove javascript Google Maps from the original page, everything will be fine and I will get the full section. Requesting another page that does not use the map API also works fine.

I see a related question here, but the workaround is not fully described: https://github.com/assaf/zombie/issues/250

Can someone help me with a complete workaround?

Here is the zombie.js code:

suite('Zombie Sign In', function() {

    test('Home page should have sign-in link', function(done) {
        var browser = new Browser();
        browser.debug = true;
        browser.authenticate().basic(conf.basicAuth.username, conf.basicAuth.password);
        browser.visit(conf.baseURL, function(e, browser) {
            console.log(browser.html()); // here is where I get the empty body section
            browser.clickLink("Sign In", function() {
                browser.text("title").should.eql('my title');
                done();            
            });
        });
    });
});
+5
source
1

- API . , , :

https://developers.google.com/maps/documentation/javascript/tutorial#asynch

:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE" type="text/javascript"></script>
<script type="text/javascript">
  function initialize() {
    var map = new google.maps.Map(/* ... */);
  }

  window.onload = initialize();
</script>

( ):

<script type="text/javascript">
  function initialize() {
    var map = new google.maps.Map(/* ... */);
  }

  function loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE&callback=initialize";
    document.body.appendChild(script);
  }

  window.onload = loadScript;
</script>

, callback script.src( initialize, , ) - Google script.

Zombie.

+3

All Articles