Home > front end >  How to retrieve just the integer from a string variable that contains string and string type numbers
How to retrieve just the integer from a string variable that contains string and string type numbers

Time:11-16

I am creating a test case in Robot framework that checks the memory usage of an application and does some further actions. I am running a keyword that executes a command on command line and returns the output.

I am using that keyword to run the command wmic process where name=\"${executableName}\" get WorkingSetSize

If we run this command on command prompt we get an output like

WorkingSetSize
353242342

I am executing this command in robot framework using a keyword but I want to modify the output such that I can just store the number in the variable without the "WorkingSetSize" or newline found in my output. How should I approach this?

CodePudding user response:

If the string contains space in between string and Number, then try this

    ${String and number}    hello 123

    ${number only}     Evaluate    "${String and number}".split(" ")[1]

Same way you can use any separator in the split function.

  • Related