7 Answers, 1 is accepted
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
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
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)
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
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 ?
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