我可以将背景与黄瓜中的例子一起使用吗? [英] Can I use background with examples in cucumber?

查看:86
本文介绍了我可以将背景与黄瓜中的例子一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过所有场景的第一步来举例说明。但是所有方案的第一步都是相同的,只是一个要素不同。因此,我想在后台完成所有步骤,并希望在后台添加示例。
简而言之,我想导航到Facebook,Twitter,Google和youtube页面,然后单击一个元素。我可以为此使用以下内容吗?

I want to pass an example with first step of all scenarios. But first step in all scenarios are same, just one element is different. So I want to all that step in background and want to add examples with background. In short suppose I want to navigate to facebook, twitter, google and youtube page and click on one element. Can I use following thing for that??

Background: Open the web-page
Given Open the <web_page> website
Examples:
|web_page|
|facebook|
|twitter|
|google|
|youtube|

Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...


推荐答案

您将能够使用以下数据表实现背景-

You shall be able to implement background with Data table as below -

Background: Open the web-page 
Given Open the <web_page> website
|web_page| 
|facebook| 
|twitter| 
|google| 
|youtube|

如何将网页的正确值从数据表传递到步骤实现方法?

How to pass correct value of web page from Data table to step implementation method ?

这样做的方法可能很少,其中之一就是检查您的方案名称,并根据该名称从Data中找到相应的值要加载的网页表。

There could be few ways doing so and one of them shall be check your scenarios name and based on that find corresponding value from Data table of web page to be loaded.

这篇关于我可以将背景与黄瓜中的例子一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆