EDITED
See my second post sent later in the day. In that post there is a video showing you how to create the exact test you are trying to create
-----
This is the way I would do this:
Firstly, when searching/googling for how to do steps 1 and 2, you would type the following (these are actually 1 step) 'testcomplete, how to extract text from app'.
- google 'testComplete, how to extract text from app'. This will lead you to the following page:
usually test complete is great when it comes to documentation. You can easily find what you need by typing 'TestComplete <your question here>'. However, i had trouble this time finding the video. I did eventually find it. The following video shows how to grab text from your app and then store it in a variable (this works the same for desktop and web apps).
https://www.youtube.com/watch?v=l3F52-Z9DOE
- Then you will want to do as rraghvani said and create a javascript function to extract the number from the text. ChatGPT will be your go to for writing javascript functions. You don't need to know much about programming to create a javascript function when you use ChatGPT and ChatGPT will help you learn basics about programming as you use it because it also explains in detail the code that it returns.
I typed into chatGPT:
"Hi Chat, I need a javascript function that will take in an alphanumeric string and pass back the numeric part of the string." OR better ...
"Hi Chat, I need a javascript function that will take in an alphanumeric string and pass back the numeric part of the string as a number (a float/double). The value is in the format "##,###.## USD" (no quotes, of course)".
Copy the answer (the javascript function) ChatGPT gives you into a script file in TestComplete. I put the code below. It is a good idea to start learning how to use ChatGPT.
- Add the javascript object you created in step 2 to your keyword test you started in step 1. Watch the following video (not ideal video but good enough):
https://www.youtube.com/watch?v=z0VuGO4mVBw
function extractFloatValue(inputString) {
// Use a regular expression to match the numeric part of the string
const match = inputString.match(/[\d,]+\.\d+/);
if (match) {
// Remove commas and convert the matched numeric part to a floating-point number
return parseFloat(match[0].replace(/,/g, ''));
}
// Return null if no numeric part is found
return null;
}