【发布时间】:2013-02-14 18:13:27
【问题描述】:
我是 cucumber/capybara/ruby 的新手,在 php 构建的网站上尝试 BDD。
检查:
不同的链接将用户引导到正确的页面:“prod-integration-mycompany.com”
情况:
在这个页面上我有一些独特的链接(大约 20 到 50 个),链接看起来像,
<a href= " /edition/123456"> BookTitle 01 by <a class="author" title= "Dan Romio" href=" >/author/Dan+Romio/112212">Dan Romio</a>' <a href= " /edition/654321"> BookTitle 02 by <a class="author" title= "Maggi Smith" href=" >/author/Maggi+Smith/11332">Maggi Smith</a> <a href= " /edition/56232"> BookTitle 03 by <a class="author" title= "Dan Romio" href=" >/author/Dan+Romio/112212">Dan Romio</a> etc…
我要检查的内容:
我想检查用户单击版本链接时,该页面的 与 BookTittle 匹配。我可以一步一步做完
When …… within(:css, 'dd[@id = "(css ID here)"]') do click_on '' or click_link (name of the link) end end Then ………|text| check_destination(text) end
在 env.rb 上,我有一些函数,例如“check_destination()”和不同的断言:
def check_destination(paramText) new_window = page.driver.browser.window_handles.last page.within_window new_window do path = URI.parse(current_url) assert_include(paramText,path) end end
那么?有什么问题?:
问题是当我想做一大堆它们时,我不知道我将如何使用数组的 key=> 值并在我的步骤中循环它们。是桌子吗?是课堂吗?我有点没概念/想法了……有什么想法吗?关联 ?顺便说一句,如果我浪费你的时间,我很抱歉。谢谢。
【问题讨论】:
-
检查每个链接是否真的有价值(即如果其中一个链接有效,其他链接之一断开的可能性有多大)?
-
@JustinKo:这可能是版本 id 不存在/不存在的情况,或者即使它存在也可能是 redis(缓存)问题。我不会说检查这些链接有很大的价值,但我可以在不同的情况下使用相同的逻辑。谢谢。
标签: ruby arrays hyperlink cucumber capybara