Ruby on Rails:Xpath:无法检索 XPath
这是我得到的错误:
NativeException: java.lang.RuntimeException: Could not retrieve XPath >//id[@class='open'//@id='status_open']< on HtmlPage(http://cucumber.test.com/proposals/view-me/edit#)@17325460 (Culerity::CulerityException)
这是我的 Cucumber 命令
Then the "li" tag with the id "status_open" should have the class "open"
这是我的步骤定义
Then /^the "([^\"]*)" tag with the id "([^\"]*)" should have the class "([^\"]*)"$/ do |tag,id,clas|
if page.respond_to? :should
page.should have_xpath("//#{tag}[@class='#{clas}',@id='#{id}']")
else
assert page.have_xpath("//#{tag}[@class='#{clas}',@id='#{id}']")
end
end
,这是 HTML:
<li class="open" id="status_open">
<a href="#">
Open
</a>
</li>
基于此教程,它似乎应该可以工作:
http://www.w3schools.com/xpath/xpath_syntax.asp
想法?
This is the error I get:
NativeException: java.lang.RuntimeException: Could not retrieve XPath >//id[@class='open'//@id='status_open']< on HtmlPage(http://cucumber.test.com/proposals/view-me/edit#)@17325460 (Culerity::CulerityException)
This is my Cucumber command
Then the "li" tag with the id "status_open" should have the class "open"
This is my step definition
Then /^the "([^\"]*)" tag with the id "([^\"]*)" should have the class "([^\"]*)"$/ do |tag,id,clas|
if page.respond_to? :should
page.should have_xpath("//#{tag}[@class='#{clas}',@id='#{id}']")
else
assert page.have_xpath("//#{tag}[@class='#{clas}',@id='#{id}']")
end
end
and here is the HTML:
<li class="open" id="status_open">
<a href="#">
Open
</a>
</li>
it seems like it should work, based on this tutoraial:
http://www.w3schools.com/xpath/xpath_syntax.asp
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
//id[@class='open'//@id='status_open']
不是语法上正确的 XPath 表达式。
我必须猜测...也许你想要:
//li[@class='open' and @id='status_open']
//id[@class='open'//@id='status_open']
is not a syntactically correct XPath expression.
I have to guess... Maybe you wanted:
//li[@class='open' and @id='status_open']