0

我在使用 Capybara (2.0.0) 进行 Cucumber 测试时遇到问题。

page.html这是在 RackTest 中运行时生成的(有效)html :

<?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>

Capybara 方法click_on("Show Stuff")返回错误:

  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'

使用 Selenium 驱动程序时它工作正常,有趣的是,它有一个不同的源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>

谢谢你的帮助!我需要它!

4

1 回答 1

1

属性必须全部小写。设置按钮type=submit解决了问题

于 2012-11-28T14:28:39.097 回答