Summary
This article is for describing how a PowerShell script can be executed via a Login VSI customized workload, which would type a random string from an array. This could include sending a random string from an array to any field that's focused on. This could be helpful in sending a random username, patient name, etc.
Note: this is provided as-is for ease-of-use, and is not officially supported. Please contact your Account Manager or support@loginvsi.com for information regarding Professional Services offerings, including Workload Customization.
Steps
- First, edit a Login VSI workload to navigate to a field in a desktop or web application. This could be done by VSI_Type_Fixed and VSI Key Commands, VSI_ControlFocus, or VSI_Mouse_Click. Also, a combination of the aforementioned functions could be used to navigate to a text field. Please see the Login VSI Workload Language Reference Guide for the functions supported in Login VSI workloads.
- After the target text field is being focused on by the Login VSI workload, run a VSI_ShellExecuteWait function which executes the PowerShell script, which contains the code similar to the following, which is for a scenario in which a random username is desired to be typed (note the usage notes):
- <# This is choosing a random string from the array that contains username1 and username2 and assigning it to the variable named username. -InputObject is a comma-separated value #>
$username = Get-Random -InputObject username1,username2
<# Adding the assembly named System.Windows.Forms so the string can be sent #>
Add-Type -AssemblyName System.Windows.Forms
<# Amount of time to wait before sending the randomly selected string. This example is 3 seconds #>
timeout 3
<# This will send the randomly selected string to the field that's already been focused on #>
$username.ToCharArray() | ForEach-Object {[System.Windows.Forms.SendKeys]::SendWait($_)}
- <# This is choosing a random string from the array that contains username1 and username2 and assigning it to the variable named username. -InputObject is a comma-separated value #>
- The VSI_ShellExecuteWait function in the workload would look like, if the path and filename was \\loginvsiserver\loginvsishare\randomtype.ps1:
VSI_ShellExecuteWait("randomtypefunction", "\\loginvsiserver\loginvsishare\randomtype.ps1")
Properties
Applies to
Login VSI 4.x
Comments
0 comments
Article is closed for comments.