GUI: Inject JavaScript
Description
GUI: Inject JavaScript step allows the user to inject java script in a GUI automation workflow. Sometimes web control with web locators doesn’t react well as is unable to perform the action. At such times this step can be very useful to perform web actions.
tip
Inject JavaScript step works on active browser tab. In case where you want to execute JavaScript in another tab/window opened during automation, use switch window first and then add Inject JavaScript step
Configurations
| No. | Field Name | Description |
|---|---|---|
| 1 | Step Name | Name of the step. The name must be unique in a single workflow.The data type is string, and the field is mandatory. |
| 2 | Web Browser Name | You can select any one web browser from the given list. Note: You must select the same web browser which was selected in the Start Browser step. |
| Left Pane: | ||
| 3 | Get Input Fields | Click to get a list of all input fields that can be used as a part of Inject Java Script. |
| Code Snippets: | ||
| 4 | Sample Code | Double click Sample Code to populate sample code in the Inject Java Script right hand pane. Here you will find an example to make fields available to next step. Partial pseudo code for making multiple fields available to next step, var FieldName = "FieldName"; var FieldValue = "FieldValue"; var FieldName2 = "FieldName2"; var FieldValue2 = "FieldValue2"; return "<<>>"+FieldName+"::"+FieldValue+"<<>>;<<>>"+FieldName2+"::"+FieldValue2+"<<>>"; |
| Right Pane: | ||
| 5 | Inject JavaScript | Write the Java Script in the space provided. Following, is a sample Java Script showing how to set value and click a button. In this case the code sets values of username and password and clicks a login button. var chkPrint = document.getElementsByName('uid')[0].value = "mngr169997"; document.getElementsByName('password')[0].value = "YvynEtA"; document.getElementsByName('btnLogin')[0].click(); |