This is a migrated thread and some comments may be shown as answers.

Random text

7 Answers 202 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jessica
Top achievements
Rank 1
Jessica asked on 15 Dec 2011, 12:08 AM
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.

7 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 15 Dec 2011, 12:25 AM
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
0
Jessica
Top achievements
Rank 1
answered on 19 Dec 2011, 04:54 PM
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)?
0
Anthony
Telerik team
answered on 19 Dec 2011, 05:34 PM
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
0
Meera
Top achievements
Rank 1
answered on 11 Jan 2018, 08:40 PM

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)

0
Elena
Telerik team
answered on 16 Jan 2018, 09:20 AM
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!
0
Meera
Top achievements
Rank 1
answered on 18 Jan 2018, 04:08 AM

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 ?

 

 

0
Elena
Telerik team
answered on 22 Jan 2018, 08:52 AM
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!
Tags
General Discussions
Asked by
Jessica
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Jessica
Top achievements
Rank 1
Meera
Top achievements
Rank 1
Elena
Telerik team
Share this question
or