We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More

Forum Discussion

acm's avatar
acm
Contributor
9 years ago
Solved

How to Extract and Save a "substring" into a Variable for separate tests?

Good day,

 

Please see the image attached, the text string "Event id: 2172 Status: Work in progress" appears in the top right corner.  It is a long string found within CSS selector, 

#ismheader > header > div.event-message

 

How would you save "2172" for later use?  The goal here is to save the Event ID number (2172) and retrieve its details in a separate keyword test.

 

Thank you.

 

Regards,

Arlene

 

 

  • In your case, you can use Set Variable Value.  Pick your variable and then use Code Expression to get the string with your own InputString, StartPosition, and Length.

     

     

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3

    This should be of some help:

    https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/substring.html

     

    You want to start right after the first colon and take the next four characters (or whatever is appropriate) and store them in your variable.

    • acm's avatar
      acm
      Contributor

      I see, thank you.  One more question:

       

      How would you use this aqString method in a Keyword test?

       

      Thanks,

      Arlene

       

      • Marsha_R's avatar
        Marsha_R
        Icon for Champion Level 3 rankChampion Level 3

        In your case, you can use Set Variable Value.  Pick your variable and then use Code Expression to get the string with your own InputString, StartPosition, and Length.