2014-09-03 65 views
5

我有一個黃瓜場景大綱,其中示例表我想傳遞一個空字符串(「」)和換行符(\ n \ n \ n)作爲價值。我想編輯一個文本字段,我正在刪除字符串,並希望傳入空字符串或換行符。我想發送這個值,然後按回車。這看起來像這樣.sendKeys(value +「\ n」)。在示例表中,將值留空並傳遞\ n \ n \ n不起作用。文本字段中的值不會更改。
這是該方案的輪廓看起來像:黃瓜場景大綱:在示例表中傳遞空字符串「」作爲值

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  | 

如何傳遞的價值觀?
當我只是通過硬編碼值傳遞它的作品。文本字段至少被替換爲值,但我希望將其作爲佔位符。
硬編碼版本:

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 | 

任何想法?謝謝

+0

嗨@julesmummdry!你最終使用我的解決方案嗎?如果是這樣,也許你可以標記答案爲接受,如果它幫助 – troig 2017-04-05 10:39:15

回答

7

您只需將<columnName>放在您的功能定義中的「」之間。例如:

And I set name "<NewName>" for conversation 

在你的步驟定義,步驟可以像註解如下:

@And("^And I set name \"([^\"]*)\" for conversation$") 
    public void And_I_set_name_for_conversation(String newName) throws Throwable { 
     ... 
    } 

希望它可以幫助

+1

謝謝,將嘗試它......在同時發現一個不同的解決方案。所以我把這個unicode角色傳給SPACE並逃脫它(\\ u0020)。我有一個Stringparser unescapes它並將其設置爲名稱(name = StringParser.unescapeString(name);)。這適用於我,但會檢查你的tipp。謝謝 – julesmummdry 2014-10-14 14:54:55

+1

好方法。但我認爲我的解決方案更簡單。此外,與IDE的集成(IntelliJ在我的情況)期望「」鏈接每個步驟功能文件<-> Java類。試試看,祝你好運 – troig 2014-10-14 15:37:38

+1

謝謝!這有效,但更多的是解決黃瓜丟失功能的解決方法。 – ccpizza 2016-12-06 18:06:24

相關問題