assaf / zombie

Insanely fast, full-stack, headless browser testing using node.js
http://zombie.js.org/
MIT License
5.65k stars 518 forks source link

Zombie fails when TurboLinks library is used. #1142

Open djlogan2 opened 7 years ago

djlogan2 commented 7 years ago

I'm not sure which library needs to be fixed, but when I am attempting to unit test a ruby application, zombie originally crashed with an uncaught 'invalid URL' error. Tracing this down, it appears that the ruby views use the TurboLinks library, and this library likes to set the URL to an object rather than a string. It overrides 'toString()' so that it returns a valid URL, but in the attached image, you can see that URL is an object, and in 'trimControlCharacters', there is just a 'url.replace' instead of 'url.toString().replace'. My temporary fix as you can see from the screen shot was to just add toString() which solved my problem.

On my computer, this file is located at _nodemodules/whatwg-url-compat/lib/url.js

The ruby project under test is in my repository and all you have to do is this:

    browser.visit('http://whatever.com:3000', function(err){
        browser.assert.element('form input[id=employee_username]');
        browser.assert.element('form input[id=employee_password]');
        browser.assert.element('form input[name=commit]');
        browser
            .fill('[id=employee_username]', username)
            .fill('[id=employee_password]', 'kenzan')
            .pressButton('[name=commit]', callback);
    });

screen shot 2017-11-17 at 8 52 11 am