I recently ran our website through our PhantomJS testing suite and ran into JavaScript errors that I can't reproduce in my browser manually. These errors are found in the Google maps api and the text returned by Capybara is as follows:
TypeError: Unable to delete property.
TypeError: Unable to delete property.
at :215
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:19
at :214
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:20 in cf
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:21
at :176
at :31
at https://maps.gstatic.com/maps-api-v3/api/js/19/3/main.js:26 in Yf
at :178
Is this a known bug with Capybara, PhantomJS, or the Google maps API? Could the problem be caused by the user agent string in PhantomJS?
I'm using Cucumber / Poltergeist and I hacked around this in by creating the following extension:
/features/support/env.rb
Capybara::Poltergeist::Driver.new(app,
:extensions => ["features/support/ignore_gmaps_errors.js"]
)
/features/support/ignore_gmaps_errors.js
window.onerror = function(message) {
if (message == 'TypeError: Unable to delete property.') {
console.log('Ignoring gmaps error');
return false;
} else {
return true;
}
};
Google maps API experimental version was updated this morning (12/11) causing this breakage. By default when you include:
<script src="//maps.googleapis.com/maps/api/js?libraries=places"></script>
it uses the latest experimental version. Locking yourself to the latest release version:
<script src="//maps.googleapis.com/maps/api/js?v=3&libraries=places"></script>
should fix this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With