Search code examples
csvevalselenium-ideimacroskantu

Kantu Selenium IDE Store Variables With Part Of Value Saved In A Column Of Csv


You can help me, I really am at the beginning so I need help and advice to learn the language of Kantu Selenium IDE.

This is the first question:

Can Kantu Selenium IDE extract a part of the value saved in a csv column and set it as a variable?

I Give us an example:

Csv name: database.csv

Csv column 1 Values

Username||||Password||||EMAIL
Username||||Password||||EMAIL
Username||||Password||||EMAIL

delimiter |||| (4pipe)

I need to extract Username and set in variable MyUsername.

I need to extract Password and set in variable MyPassword.

I need to extract Email and set in variable MyEmail.

With Imacros i use this syntax

’ Csv
SET !DATASOURCE database.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !LOOP 1

’ Variables
SET MyUsername EVAL("’{{!COL1}}’.split(’||||’)[0].trim();")
SET MyPassword EVAL("’{{!COL1}}’.split(’||||’)[1].trim();")
SET MyEmail EVAL("’{{!COL1}}’.split(’||||’)[2].trim();")

Trim split the value inside Column 1 and grab every part with 0 1 2 and save in it variables.

With Kantu Selenium IDE how can i do a similar function ?

Kantu Selenium IDE support regex and javascript codes like imacros.

Thanks, Have a nice day


Solution

  • This is the solution, it read csv column, split the value with delimiter |||| and with 0 take the first part.

    {
      "Command": "storeEval",
      "Target": "\"${!COL1}\".split(\"||||\")[0].trim();",
      "Value": "MyVar"
    },
    

    Best Regards