2012-11-27 88 views
0

我用黃瓜測試使用水豚(2.0.0)的麻煩。水豚RackTest不能點擊或找到按鈕,但硒可以

下面是RackTest上運行時,page.html產生的(有效)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> 

的水豚方法​​返回錯誤:

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> 

感謝您的幫助!我需要它!

回答

1

屬性必須全部小寫。設置按鈕type=submit解決了問題