Random text

8 posts, 0 answers
  1. Jessica
    Jessica avatar
    2 posts
    Member since:
    Jan 2011

    Posted 14 Dec 2011 Link to this post

    Is there a way to generate random text to enter in a test step? I saw a similar thread where one could enter random numbers.
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 14 Dec 2011 Link to this post

    Hi Jessica,

    The are two approaches here:

    1. The first is without code. Navigate to a random word generator site, like here, and click the button for a new word. Then Extract that word to later data bind it to a text entry step.

    2. The second is with code. Here is an example of how to do that in C#. The following code worked for me on Bing.com:

    string path = System.IO.Path.GetRandomFileName();
    path = path.Replace(".", ""); // Remove period.
     
    // Enter text in 'SbFormQText' on Bing.com
    Pages.Bing.SbFormQText.Text = path;

    Greetings,
    Anthony
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jessica
    Jessica avatar
    2 posts
    Member since:
    Jan 2011

    Posted 19 Dec 2011 Link to this post

    Thank you, this was very helpful. This code brought back a random filename that included numbers or special characters. Do you know what the code would be to only return a random string of alpha characters (a-z,A-Z)?
  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 19 Dec 2011 Link to this post

    Hi Jessica,

    There are many examples on how to do this online. This article has been updated to demonstrate one of those examples. 

    Kind regards,
    Anthony
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Meera
    Meera avatar
    3 posts
    Member since:
    May 2015

    Posted 11 Jan Link to this post

    Hi admin, I tried the extraction step from a randongenerator website. I did all the steps mentioned in the article but the extracted password is not set in the text value. Here are the steps and the error log

    1) steps in the test

    '1/11/2018 1:56:32 PM' - 'Pass' : 28. Navigate to : 'https://passwordsgenerator.net'
    '1/11/2018 1:56:33 PM' - 'Pass' : 29. Check 'NumbersCheckBox' to be 'True'
    '1/11/2018 1:56:34 PM' - 'Pass' : 30. Check 'UppercaseCheckBox' to be 'True'
    '1/11/2018 1:56:44 PM' - 'Pass' : 31. Wait for '10000' msec.
    '1/11/2018 1:56:45 PM' - 'Pass' : 32. Click 'GenerateDiv'
    '1/11/2018 1:56:45 PM' - 'Pass' : 33. Extract input 'FinalPassText' value into DataBindVariable $(randompwd).
    '1/11/2018 1:57:17 PM' - 'Fail' : 34. Enter text 'Test128' in 'WorkSpaceContentUserPreferencesNewPasswordPassword' - DataDriven: [$(randompwd)]

     

    2) Error log
    [01/11 13:56:45,ArtOfTest.Runner.exe(16520:4),TestStudio] VisualDebugger.SetCurrentStep() : VisualDebugger::SetCurrentStep
    [01/11 13:56:45,ArtOfTest.Runner.exe(16520:4),TestStudio] VisualDebugger.CheckPause() : VisualDebugger::CheckPause::Start
    [01/11 13:56:45,ArtOfTest.Runner.exe(16520:4),TestStudio] VisualDebugger.CheckPause() : VisualDebugger::CheckPause::End
    [01/11 13:57:17,ArtOfTest.Runner.exe(16520:4),Error] ExecutionEngine.CatchExecuteStepException() : EXCEPTION! (see below)
         Outer Exception Type: ArtOfTest.Common.Design.Exceptions.ElementFindException
         Message: Unable to locate element. Details: Attempting to find [Html] element using
              Find logic
              (Html): [id 'Exact' ctl00_WorkSpaceContent_userPreferences_newPassword] AND [tagname 'Exact' input]
              Unable to locate element. Search failed!
              Learn more about finding elements here:
              http://docs.telerik.com/teststudio/troubleshooting-guide/test-execution-problems-tg/unable-to-locate-element
         HRESULT: 0x80131500 (Official ID (if app.) = COR_E_EXCEPTION, Error Bit = FAILED, Facility = FACILITY_URT, Code = 5376)
         Call Stack:
              at ArtOfTest.WebAii.Design.Execution.ExecutionUtils.WaitForAllElements(IAutomationHost host, AutomationDescriptor descriptor, Int32 timeout)
              at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteStep(Int32 order)

  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    938 posts

    Posted 16 Jan Link to this post

    Hi Meera,

    Thank you for reaching us out. 

    As far as I could see the field you want to enter the extracted value is on the initially navigated page. And the one active in that moment is still the one that generates the random password. To solve that you should insert a navigate step to load the previous page again. 

    I would recommend you first navigate to the random generator page, create the password and store into a variable - this could be also a test as step. Then proceed with the actual test as per the common scenario - navigate to the URL, enter username, enter password. login, etc. 

    I hope this will be helpful for you! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  7. Meera
    Meera avatar
    3 posts
    Member since:
    May 2015

    Posted 17 Jan in reply to Elena Tsvetkova Link to this post

    Hi Elena,

    I did follow the steps mentioned first navigating to random page, I want to use the generated password in 2 locations in the same script. My requirement is I am trying to reset a password and need to give current password and new password on the same page. I am databinding the random generated password to the new password for the first run. I need to reuse this next time to provide for current password. Is it possible to store it in local data or any other way so I can reuse the pwd ?

     

     

  8. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    938 posts

    Posted 22 Jan Link to this post

    Hi Meera,

    Thanks for your cooperation! 

    Please find a solution how you could be writing data into an excel file. I hope this will be useful to you! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top