问题描述
我有一个黄瓜场景大纲,我想在示例表中传递一个空字符串 (" ") 和换行符 () 作为值.我想编辑一个文本字段,我正在删除字符串并想传入空字符串或换行符.我想发送这个值并按回车.这看起来像这样 .sendKeys(value + "").在示例表中,仅将值留空并通过 不起作用.文本字段中的值不会改变.
场景大纲如下所示:
I have a cucumber scenario outline in which Examples table I would like to pass an empty string (" ") and line breaks () as value. I want to edit an textfield and I am deleting the string and want to pass in the empty string or the line breaks. I want to send this value and press enter. This would look like this .sendKeys(value + ""). In the Example table just leaving the value blank and pass doesnt work. Value in textfield gets not changed.
This is how the Scenario outline looks like:
Scenario Outline: Do not accept erroneous input as group conversation name (only spaces and break lines)
Given I Sign in using login <Login> and password <Password>
And I see Contact list with name <Name>
And I create group chat with <Contact1> and <Contact2>
When I open conversation with <Contact1>, <Contact2>
And I open Conversation info
And I set name <NewName> for conversation
Then I do not see conversation <NewName> in contact list
And I see Contact list with name <Contact1>, <Contact2>
Examples:
| Login | Password | Name | Contact1 | Contact2 | NewName |
| aqaUser | aqaPassword | aqaUser | aqaContact1 | aqaContact2 | |
| aqaUser | aqaPassword | aqaUser | aqaContact1 | aqaContact2 |
|
如何传递值?
当我只是将值作为硬编码传递时,它可以工作.文本字段至少被替换为值,但我想将它作为占位符.
硬编码版本:
How do I pass the values?
When I am just passing the values as hardcoded it works. The textfield gets replaced at least with the values, but I would like to have it in as an placeholder .
Hard coded version:
Scenario Outline: Do not accept erroneous input as group conversation name (only spaces)
Given I Sign in using login <Login> and password <Password>
And I see Contact list with name <Name>
And I create group chat with <Contact1> and <Contact2>
When I open conversation with <Contact1>, <Contact2>
And I open Conversation info
And I set name for conversation
Then I do not see conversation in contact list
And I see Contact list with name <Contact1>, <Contact2>
Examples:
| Login | Password | Name | Contact1 | Contact2 |
| aqaUser | aqaPassword | aqaUser | aqaContact1 | aqaContact2 |
Scenario Outline: Do not accept erroneous input as group conversation name (line breaks)
Given I Sign in using login <Login> and password <Password>
And I see Contact list with name <Name>
And I create group chat with <Contact1> and <Contact2>
When I open conversation with <Contact1>, <Contact2>
And I open Conversation info
And I set name
for conversation
Then I do not see conversation
in contact list
And I see Contact list with name <Contact1>, <Contact2>
Examples:
| Login | Password | Name | Contact1 | Contact2 |
| aqaUser | aqaPassword | aqaUser | aqaContact1 | aqaContact2 |
有什么想法吗?谢谢
推荐答案
您只需将 放在您的特征定义中的"之间.示例:
You only need to put the <columnName>
between "" in your feature definition. Example:
And I set name "<NewName>" for conversation
在您的步骤定义中,可以将步骤注释如下:
In your step definition, the step could be annotated like as follows:
@And("^And I set name "([^"]*)" for conversation$")
public void And_I_set_name_for_conversation(String newName) throws Throwable {
...
}
希望对你有帮助
这篇关于Cucumber 场景大纲:传递空字符串 ""作为示例表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!