访问场景标题和示例在黄瓜后挂钩 [英] Accessing the Scenario Title and Example in a Cucumber After hook
问题描述
如何在 我可以使用下面的代码获得标题。我的 功能文件 挂钩后 如何获取当前 这是我做的。 How can I get the current I can get the title with the code below. My Feature file After hook How to I get the current Here is how I did it.
这篇关于访问场景标题和示例在黄瓜后挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!之后的
钩子中获取当前
示例
>
场景
有几个示例
。我可以访问当前示例
正在测试吗?
:使用主帐户成功登录
假定我从登录页面开始
当我使用< acct>登录到概述页面时
然后我在概述页面
示例:
| acct |
| account1 |
| account2 |
After | scenario |
scenario.scenario_outline.title#将给我标题
示例?
scenario_title = scenario.respond_to?(:scenario_outline)? scenario.scenario_outline.title:''
scenario_title_example = scenario.respond_to?(:name)? scenario.name:''
scenario_full_title = scenario_title + scenario_title_example
Example
out of a Ruby cucumber test in an After
hook?Scenario
has several Examples
with it. Can I access the current Example
being tested? Scenario Outline: Successful login with primary accounts
Given I start on the login page
When I log into Overview page with "<acct>"
Then I am on the Overview page
Examples:
| acct |
| account1 |
| account2 |
After do |scenario|
scenario.scenario_outline.title # will give me the title
Example
? scenario_title = scenario.respond_to?(:scenario_outline) ? scenario.scenario_outline.title : ''
scenario_title_example = scenario.respond_to?(:name) ? scenario.name : ''
scenario_full_title = scenario_title + scenario_title_example