Search code examples
javaseleniumselenium-webdriverautomated-testscucumber

Added "\n" by using the split function in the method but is not working while running the Script. Can I get some inputs


/* This is my Method */

    public static void inputvalues(WebDriver driver,Map<String, String> formEntryMap,String col) 
    {
        if(formEntryMap.containsKey(columnKey))
        {   
            String [] inputInfo = formEntryMap.get(colKey).trim().split("\n");
            
            for(String inputItem:inputInfo)
            {
                String xPath = XpathofInputfield
                inputEntry(driver, xPath,inputItem);
        
            }
        }
    }

Feature File is defined as below:

| Column | Value         |
                                                                       
| Status | 542567 785454 |

Now When I Run the above file it should add the values one below the other in the status text box. So while adding it should be like: 542567
785454
But the issue is it is not adding the value like that and is just adding as per what is given in the Feature File.
My requirement: It should split and add the value in the Newline by reading from the method.

I would need a solution for this. Can someone please give your inputs.


Solution

  • See if this works: Change your split() to

    String [] inputInfo = formEntryMap.get(colKey).trim().split("\\W+");
    

    Updated Code: Your inputEntry() should have something like this:-

    xpath.sendKeys(inputItem,"\n");