Forum Discussion

jg0888's avatar
jg0888
Contributor
7 years ago
Solved

Using the KeywordTest, is there a way to set the first x number of characters from last operation?

I want to search from specific value that displays on the UI. It displays as "Lastname, Firstname", and I want to select the "Lastname" before the comma. If there isn't a way to do this, can I select the first 4 characters to then set the text into a search bar.

 

These values change depending on different values on the UI. Is there a way to do this?

 

 

3 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    You can get a full string and then get a slice (first 4 characters) from it.

     

    fullString = 'John, Doe'
    
    In JScript, JаvаScript: 
    
    subString = fullString.slice(0,4)


    In Python:

    subString = fullString[0:4]

    Output: subString == "John"

    etc...

     

  • Awesome! I knew there had to be a good way to do this. As a non-developer using TestComplete, it is so cool to see that SmartBear has already configured these things into the KeywordTest Operations and Object Methods.

     

    I called the Object Method of aqString and Operation SubString to accomplish the task I needed within my KeywordTest.

     

    Thanks!