Skip to content

Instantly share code, notes, and snippets.

@floehopper
Created September 15, 2010 08:25
Show Gist options
  • Select an option

  • Save floehopper/580415 to your computer and use it in GitHub Desktop.

Select an option

Save floehopper/580415 to your computer and use it in GitHub Desktop.
illustrates a problem i'm seeing with capybara-envjs
# HTML file with form including textarea
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>test</title>
</head>
<body>
<form action="/blah" id="wemForm" method="post">
<textarea id="wem" name="wem"></textarea>
<input name="commit" type="submit" value="submit" onclick="wemFormSubmit(); return false;"/>
</form>
<ol id="logger">
</ol>
<script type='text/javascript'>
//<![CDATA[
function wemFormSubmit() {
logMessage("wem=" + document.getElementById("wem").value);
logMessage("submitted");
};
function logMessage(message) {
body = document.getElementById("logger");
var li = document.createElement("li");
li.innerHTML = message;
body.appendChild(li);
};
//]]>
</script>
</body>
</html>
# Open this file directly in the browser
# Type "blah" into the textarea
# Click "submit" button
# See the following two logger list items added :-
# 1. wem=blah
# 2. submitted
# Cucumber feature using capybara-envjs v0.1.6
Feature: Wem
@javascript
Scenario: Wem
Given I am on the test page
When I fill in "wem" with "blah"
And I press "submit"
Then I should see "submitted"
Then show me the page
# Map the "test page" to the HTML file above
# Run the Cucumber feature
# See the following two logger list items added on the opened page :-
# 1. wem=
# 2. submitted
# Why is it that in the Cucumber test the value of the textarea is an empty string and not the submitted value of "blah"
# even though when I execute the following the browser console :-
#
# > document.getElementById("wem").value
#
# I see :-
#
# "blah"
# If I change the textarea to an input[type=text] the problem goes away
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment