创建动态cucumber_steps以检查页面上的链接 [英] Creating dynamic cucumber_steps to check for links on a page
本文介绍了创建动态cucumber_steps以检查页面上的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我想让场景大纲循环所有的各种组合,这样我就不必编写一堆场景。
Basically I want the scenario outline to loop through all of the various combinations so that I don't have to write a bunch of scenarios. I want to have it visit the starting page and then check to see if the links are there however I've hit a barrier.
黄瓜功能 >
Scenario Outline: As a user I need links in order to navigate the site
Given I am a '<user>'
When I am at the <page> page
Then I should see a link to '<link>'
Scenarios: As a user that is not logged in
| user | page | link |
| not_signed_in_user | / | contact |
黄瓜功能步骤
Given /^I am a 'not_signed_in_user'$/ do
@user = nil
end
When /^I am at the (.+) page$/ do |starting_page|
visit starting_page
end
Then /^I should see a link to (.+)$/ do |link|
pending
end
我需要使用类似:
response.should have_selector('a,':href => link_path,
:content => link )
但这不会动态工作,因为它只会检查link_path ...
but that won't work dynamically as it will just check for link_path...
推荐答案
这听起来像你想使用 send(#{link} _path)
这将生成链接使用路由助手,我认为这是你想要的。
It sounds like you want to use send("#{link}_path")
here. That would generate the link using the routing helper which I think it is what you want.
这篇关于创建动态cucumber_steps以检查页面上的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文