Debugging Firefox Failures on Travis
We recently had a Capybara test suite start reliably failing only on Travis CI because of an unexpected modal dialog.
Modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError) [remote server] file:///email@example.com/components/command_processor.js:10901:in `nsCommandProcessor.prototype.execute' [remote server] file:///firstname.lastname@example.org/components/driver_component.js:7744:in `Dispatcher.executeAs/<' [remote server] file:///email@example.com/components/driver_component.js:7890:in `Resource.prototype.handle' [remote server] file:///firstname.lastname@example.org/components/driver_component.js:7837:in `Dispatcher.prototype.dispatch' ...
An easily understandable error, but this was at the end of a Scenario, not hooked to any steps, there were no alerts or prompts in the app anywhere, and completely unreproducible outside of Travis’s environment. After numerous attempted fixes, all of which were dead ends, I disabled the test and reached out to Travis to see if they could help out, and help out they sure did. They gave me access to a debug VM with X11 Forwarding enabled! These VMs come with many common services already installed (MySQL, PostgreSQL, ElasticSearch, Redis, etc), so all I had to do was set up the project and run the tests.
Sure enough, the test in question threw up a dialog, a dialog I had never seen before: “This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?” A quick search of this text found a large number of support requests to Mozilla, such as https://support.mozilla.org/en-US/questions/792131 and https://support.mozilla.org/en-US/questions/969705. This dialog comes from Firefox’s Accessibility system, is default to on, and is easily disabled via profile settings. Changing the Firefox profile in Capybara is relatively easy:
Capybara.register_driver :selenium do |app| profile = Selenium::WebDriver::Firefox::Profile.new # Turn off the accessibility redirect popup profile["network.http.prompt-temp-redirect"] = false Capybara::Selenium::Driver.new( app, :browser => :firefox, :profile => profile ) end
Boom, tests fixed, Travis is green and we’re all happy! Travis has also updated their GUI and Headless Browsers page to include this information. So huge props to the Travis team being readily available to help out. We love Travis, we use them for all of our CI needs, and you should too!
 Using SSH’s X Forwarding is simple with
ssh -X [host]. This requires a machine with X11 installed. As I work on a Mac prefer not to have that installed, I set up an Ubuntu install in VMWare (VirtualBox works just as well) and SSH’d in from there.