Select specific text from storetext value

hi, i want to separate out specific text from storetext value.


i select a value by xpath selection on web page which is “3214 is the lucky number” or “5847 is the lucky number” which is stored by storetext command as the whole sentence but the numbers are varied during each loop.

is there any way to store “3214” or “5847” in the above example and omit “is the lucky number”

thanks in advance.

You can do this using javascript.

You may check for some string manipulation in Javascript and for how-to build and run javascript code.

Here one approach using substr, suposing all numbers are 4-digits long, beginning at position 0:

Command: storeValue
Target: xpath=yourFieldDescriptor
Value: myString

Command: executeScript_Sandbox
Target: return ${myString}.substr(0,4)
Value: myNumber

Command: echo
Target: My lucky number is ${myNumber}

1 Like

Thank you hectorbot for the wonderful solution. I was wondering whether there are other approaches too in such cases. Thanks again.