Posted over 2 years ago. Visible to the public. Repeats.

Debugging cucumber feature with javascript + firefox vnc

TL;DR Debugging problems with javascript errors in cucumber tests is sometimes easier in the browser. Run the test, stop at the problematic point (with Then pause from Spreewald 1.7+) and open VNC for Firefox.

Features:


Given there is a cucumber scenario which looks like this (many of the steps are part of the spreewald gem):

Copy
@javascript Scenario: Autocomplete city for station Given there is a city with the name "Munich" And there is a station with the name "Munich main train station" When I go to the form for the station above And I fill "City" with "Mun" And I click on "Munich" And I press "Save" Then I should see a success flash And I should be on the page for the station above And I should see "City Munich"

Lets say, the autocomplete is not working. It will fail, as there is no element with the text "Munich". When the screenshot doesn't help you, here is what you can do, to debug the problem in the browser.

Add this step to your step definitions (it is extracted from spreewald's internal steps):

Copy
Then(/^wait for a enter key stroke$/) do print 'Press enter to continue...' STDIN.getc end

Change your Scenario:

Copy
@javascript Scenario: Autocomplete city for station Given there is a city with the name "Munich" And there is a station with the name "Munich main train station" When I go to the form for the station above Then I wait for a enter key stroke And I fill "City" with "Mun" And I click on "Munich" And I press "Save" Then I should see a success flash And I should be on the page for the station above And I should see "City Munich"

Open you vnc with geordi: geordi vnc

Now you can dig in deeper and figure out what's wrong with your autocomplete.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Emanuel De
Last edit:
over 2 years ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Emanuel De to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more