Fitnesse : How to save a value in a variable from a task name and form title ?

Hi All,

Need your help in achieving below scenario using Fitnesse.

I want to verify  task name has the following format: Submit Month YYYY AssetClass Fund Characteristics Data” and  store values of "Month YYYY AssetClass" in 3 different variable and use it somewhere later in the flow.

Example :- Submit May 2017 ABC FUnd Characterstics Data

Var 1 = May

Var 2= 2017

Var 3= ABC

Please can somebody help me with the suggestions?

 

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • Hi Anu,
    Here is some code that may help you.

    Use a regular expression (^\S+\s)(\S+\s?)(\S+\s?)(\S+\s?) this will give you four groups
    Full match 0-20 `Submit May 2017 ABC `
    Group 1. n/a `Submit `
    Group 2. n/a `May `
    Group 3. n/a `2017 `
    Group 4. n/a `ABC `

    The problem is to identify the correct task in the Task list in my case I was good to just find post.

    | click on menu | Tasks |
    |$VAR1= | get regex | (^\S+\s)(\S+\s?)(\S+\s?)(\S+\s?) | group | 1 | from task name containing text | post |
    |$VAR2= | get regex | (^\S+\s)(\S+\s?)(\S+\s?)(\S+\s?) | group | 2 | from task name containing text | post |
    |$VAR3= | get regex | (^\S+\s)(\S+\s?)(\S+\s?)(\S+\s?) | group | 3 | from task name containing text | post |
    |$VAR4= | get regex | (^\S+\s)(\S+\s?)(\S+\s?)(\S+\s?) | group | 4 | from task name containing text | post |


    You can now reference the variables in your script as ${VAR2} etc.

    I searched for "Request post approval changes 1705-21179 SPD"

    $VAR1<-[Request ]

    $VAR2<-[post ]

    $VAR3<-[approval ]

    $VAR4<-[changes ]

    I hope this helps,

    Magnus

  • Thankyou so much magnus . This helped me :)
Reply Children
No Data