Forum Discussion

rhu's avatar
rhu
Contributor
11 months ago
Solved

How to assign a copied text string to a variable?

My keyword test looks like:
Open a web page
Make a swagger request
Then I get the swagger result (lines of text) mark a part of it and copy it.
After that i set it to a variable
So it looks like:
Item: textnodeSelectADefinition Operation: keys Value: "^c"
Item: Set Variable Value Operation: Kdnr [Project) Value: LastResult
Then it open an other page and try to enter it into a special field
If i do that by pasting with value "^v" it is working
If i try with the Variable it is not (seem that entering the text to the variable did not work).  Item: textbox5 Operation: Set text Value: Project.Variable:Kdnr
So what did I wrong?
How can i past the copied text into a variable and use the variable later for my test?

  • Thanks for help.
    I was now able to solve the problem.
    I used the object property to find the correct text and assigned it to a persistent variable as i needed the customer number later on at another test.
    so the test-step could look like this

    Item: Set Variable Value Operation here i selected the Persistent variable Value - here i entered the object propertiy.
    Nevertheless it is still not perfect as my customer number is always unique, but when running the test again selfhealing finds the new number, copies it and the test is working with the yellow symbol

  • If you are trying to extract the customer number from a string, then think about using regular expression.

     

    Ideally, you shouldn't use ^c and ^v to copy and paste text. Use the Object Spy tool to see which properties you can use, such as contentText. And then work from there.

3 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you are trying to extract the customer number from a string, then think about using regular expression.

     

    Ideally, you shouldn't use ^c and ^v to copy and paste text. Use the Object Spy tool to see which properties you can use, such as contentText. And then work from there.

  • rhu's avatar
    rhu
    Contributor

    Thanks for help.
    I was now able to solve the problem.
    I used the object property to find the correct text and assigned it to a persistent variable as i needed the customer number later on at another test.
    so the test-step could look like this

    Item: Set Variable Value Operation here i selected the Persistent variable Value - here i entered the object propertiy.
    Nevertheless it is still not perfect as my customer number is always unique, but when running the test again selfhealing finds the new number, copies it and the test is working with the yellow symbol