Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber Scenario Outline: Passing empty string " " as value in Examples table

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

like image 938
julesmummdry Avatar asked Sep 03 '14 14:09

julesmummdry


1 Answers

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

like image 125
troig Avatar answered Oct 27 '22 17:10

troig