Search code examples
capybaraselenium-webdriverrack-test

Capybara RackTest cannot click or find button but Selenium can


I'm having trouble with a Cucumber test using Capybara (2.0.0).

Here's the (valid) html generated by page.html when running in RackTest:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>EmbeddedUiWeb</title>
</head>
<body class="embedded_ui">

<form action="/patient_context/test_host" id="patientidentity" method="POST">
  <input id="root" name="root" type="text" value="root"/>
  <input id="extension" name="extension" type="text" value="extension"/>
  <input class="btn" type="Submit" value="Show Stuff"/>
</form>


</body></html>

The Capybara method click_on("Show Stuff") returns the error:

  Unable to find link or button "Show Stuff" (Capybara::ElementNotFound)
  org/jruby/RubyBasicObject.java:1704:in `__send__'
  org/jruby/RubyKernel.java:2101:in `send'
  org/jruby/RubyBasicObject.java:1704:in `__send__'
  org/jruby/RubyKernel.java:2101:in `send'

It works fine when using the Selenium driver, which interestingly has a different source generated by page.html

<HTML><HEAD><META content="IE=8.0000" http-equiv="X-UA-Compatible">
<TITLE>EmbeddedUiWeb</TITLE></HEAD>
<BODY class=embedded_ui>
<FORM id=patientidentity method=post action=/patient_context/test_host>
<INPUT id=root value=root type=text name=root></INPUT> 
<INPUT id=extension value=extension type=text name=extension></INPUT> 
<INPUT class=btn value="Show Stuff" type=submit></INPUT> 
</FORM>
</BODY></HTML>

Thanks for your help! I need it!


Solution

  • attributes must be all lowercase. Setting the button type=submit solved the problem