How can i extract a specific part of a string

1 Answer 134 Views
Elements
James
Top achievements
Rank 1
James asked on 11 Apr 2022, 04:21 PM

In my example the string below is in a single element in my web page. When i use the "extract" step, it extracts the entire string, however, i want to be able to extract or use only the reference in this string. How is that achieved?

See Bargain Reference of BBSTI22DF9504388


Note, this reference is different each time. 

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 13 Apr 2022, 12:31 PM

Hello James,

Test Studio extraction steps do not support string modifications out-of-the-box. However there is a flexible solution, which you can adjust as per your specific requirements. Here are the steps and notes you can follow: 

  1. Use the extracted variable into coded step 
    • Once you have used an extraction step in a test, you can use the value of that variable into a coded step.
    • Then get its value and set this into a new variable in the code.

  2. You can use some C# code to work with the string and take only the part you need to. 

  3. Once you have the desired part of the string, assign this back to an extracted variable - you can use the initial one, or create a new one.

  4. In this part of the article there is an example and a sample project to download. The project demonstrates scenario, which is very similar to the one you need to cover. 

I hope this suggestion will work for you. Don't hesitate to get back with any further questions you might have on the topic.

Thanks for your cooperation in advance.

Regards,


Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Tags
Elements
Asked by
James
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or