I have the below method:

PUBLIC methodname(WebDriver driver,formEntryMap<String,String>,String Colkey)
String Xpath = This will have the xpath of the input text box

This will read the value from the col

Feature file : Column | Value| SuceessNo | 1212 1414 |

Basically, the success 1212 and 1414 should be entered one below the other in the textbox so the input should be :



With the given method can someone give me inputs on how to "\n" in this method.

  • 1
    I would like to express that ALL questions related to Selenium are viable on this site. This site is the result of a merger between Selenium and Software Quality sites, and we should continue to honor that merger.
    – corsiKa
    Jul 7, 2021 at 2:59

2 Answers 2


For the table value put in something like "newline".

Feature: Foo
   Scenario Outline: Bar
     Given ...
     When I input <value>
     Then ...

       | value |
       | 1212  |

Then in the Step Definition just check for it.

public WhenIInput(string value) {
   if (value.toLower() == "newline"){
   else {
  • thanks for the response but_my question is i dont want to enter the text newline in the feature file and want to enter it only in the method:
    – user49933
    Jul 6, 2021 at 3:07
  • So in the method:Xpath.sendKeys(formEntryMap.get(colKey)); Xpath.sendKeys("newline"); this will not work how do i add this in the method to make it work
    – user49933
    Jul 6, 2021 at 3:08
  • String [] inputInfo = formEntryMap.get(columnKey).trim().split("\n"); for(String inputItem:inputInfo) { String xPath = Xpathofinputfield .inputEntry(driver, xPath,inputItem);
    – user49933
    Jul 6, 2021 at 5:13
  • given like this but still not adding the value in the next line any suggessions pls
    – user49933
    Jul 6, 2021 at 5:13

Different types of testing services are provided by IT Companies like security testing services, performance testing.. etc.,

Here we can add new line using "\n" in java and using split function of string we can separate data based on condition we specify.

Below is the code:

String excelData = "1112 1456";

String temp[] =excelData.split(" ");

excelData = temp[0] + "\n" + temp[1];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.