Forum Discussion

marogo's avatar
marogo
New Contributor
15 years ago

Send random integer or string value to Edit control

Hi:)



How to send random integer or string value to Edit control in my Delphi application? I would like use some TestComplete script

which has simple function in Delphi to generate specific random key string like this:



function GenerateRandomKey: String;

Begin

  Result:=IntToStr(Random(1000))+'-'+IntToStr(Random(5000));

End;



I don't know how to assign this function from script with wText[Set] action.



Best regards.

M.

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Community Hero
    Hi Marek,







    Copy and paste your function to TestComplete script (if you are using DelphiScript, the function should work as it is, otherwise, translate it to the script language used in your TestComplete test project).



    Then, from test script code, use something like this:

    <TheTargetEditControl>.wText := GenerateRandomKey;



    Does this help?
  • marogo's avatar
    marogo
    New Contributor
    I would like assign result of my function to "wText" like on attached screenshot, but it doesn't work

    How should I do it correctlly? Please give me example step by step.



    M.

  • Hi Marek,





    If you want to use your code in a keyword test, you need to add the code to a script unit within your project and run it using the Run Script Routine operation. After that, you need to set the value of the On-Screen Action operation to "Last Operation result". I've created a sample project for you demonstrating how to set a value of a text field in the Orders sample application shipped with TestComplete.


  • marogo's avatar
    marogo
    New Contributor
    Thank You for help and example!



    Best regards:)

    Marekk