Forum Discussion

Chowdhary's avatar
Chowdhary
Contributor
7 years ago

Datasource to Teststep

Hi All,

 

I have a data source for the full name, I was getting the fullname to my request as ${DataSource#FullName}

 

If I want to use the same fullname to Firstname and Last name how to call it ?

 

I  want to use the same name to Firstname, Lastname & Fullname ?

 

Help me out..

 

 

1 Reply

  • avidCoder's avatar
    avidCoder
    Super Contributor

    Hey. I think you can use groovy split to workaround on this scenario:

     

    String fullname = context.expand( '${DataSource#FullName}' )

     

    Lets say, fullname prints "John Doe"

     

    Then split it using split() function and store it inside firstname and lastname:

     

    String [] nf = fullname.split(" ")

    log.info "Firstname :-" +nf[0]

    log.info "Lastname :-" +nf[1]

     

    And, store into variable:

     

    String firstname = nf[0]
    String lastname = nf[1]

     

    Hope, it works for you.