Cucumber Scenario Outline: Passing empty string “

2019-02-05 02:45发布

I have a cucumber scenario outline in which Examples table I would like to pass an empty string (" ") and line breaks (\n \n \n) 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 + "\n"). In the Example table just leaving the value blank and pass \n\n\n 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 | \n\n\n\n      |

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 \n\n\n\n\n for conversation
Then I do not see conversation \n\n\n\n\n in contact list
And I see Contact list with name <Contact1>, <Contact2>

Examples: 
  | Login   | Password    | Name    | Contact1    | Contact2    |
  | aqaUser | aqaPassword | aqaUser | aqaContact1 | aqaContact2 |

Any ideas? Thanks

1条回答
祖国的老花朵
2楼-- · 2019-02-05 03:24

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 {
      ...
   }

Hope it helps

查看更多
登录 后发表回答