TestProject Forum
Powered by leading experts in the test automation community

How to get specific text in an element?

In my screencap, I would like to get text ‘USD 4,598,525.1’ (or ‘4,598,525.1’, its more better), but the text I get is ‘USD 4,598,525.1 Refresh’.
I have tried to copy the XPath/ Full XPath of ‘USD 4,598,525.1’ in Inspect, but it is not able to detect it.
May I know any way to get it, or could I exclude the ‘Refresh’ word in the text I get?
So far I only use get text. I am not sure could get attribute value/ tag name/ css value to be used. Thank you.

Hello @tomsonycs, thanks for reaching out.

here are two ways you can do handle it:

  • Save the “Get Text” output into a parameter, create a step which performs “Remove non numeric characters” action, provided by “Numeric Utils” addon, and set the parameter saved in “Get Text” action.

notice: using this action, commas characters will be remoted as well:

image

  • in case you want the commas characters not to be removed, you can use the “Get substring in range” action provided by the “String Utils” addon

by setting the indexes of the number in the string, you can retrieve the required substring, in your case, BeginIndex is 4 and EndIndex is 16.

Thank you for your quick response, These 2 ways are great and your screencaps provided are fantastic. I will try them later.
And there is one question I wanna ask for a long time. Where does your company make a profit? I mean we enjoy a great application and helpful forum without paying any money. It doesn’t make sense. Or would TestProject be charged in the future?

Hey @tomsonycs,

TestProject has become part of the Tricentis product family, expanding Tricentis’ position as #1 in test automation with added support for open source testing . With TestProject, teams can scale and simplify web and mobile testing, regardless of skill level or company size. As a thank you to the awesome testing community, we’ve decided to provide TestProject at absolutely no cost . We hope you enjoy this awesome free tool - We built it for you !