JavaEdit Object
Description
A Java edit box.
Operations
The sections below list the built-in methods and properties that you can use as operations for the JavaEdit object.
Note: You can also view a list and descriptions of the JavaEdit description properties, for use in object repository descriptions, programmatic descriptions, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.
Methods
Activate | Activates the edit box. |
CaptureBitmap | Saves a screen capture of the object as a .png or .bmp image using the specified file name. |
Check | Checks whether the actual value of an item matches the expected value. |
CheckProperty | Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout. |
ChildObjects | Returns the collection of child objects contained within the object. |
GetAllROProperties | Returns the collection of properties and current values from the object in the application. |
Click | Clicks the specified location with the specified mouse button. |
ClickLink | Clicks the link with the specified name in the edit box. |
CreateObject | Creates an instance of any Java object within your application. |
DblClick | Double-clicks the specified location with the specified mouse button. |
Delete | Deletes the specified text. |
FireEvent | Simulates an event on a test object using one of several pre-defined event constants. |
FireEventEx | Simulates an event on a Java test object, given the ClassName, Event ID, and Event Parameters. |
GetROProperty | Returns the current value of the description property from the object in the application. |
GetStatics | Returns the Java object capable of accessing static members (methods and fields) of the specified Java class. |
GetTOProperties | Returns the collection of properties and values used to identify the object. |
GetTOProperty | Returns the value of the specified description property from the test object description. |
Highlight | Highlights the object in the application. |
Insert | Inserts a text string into the specified location in a edit box. |
MouseDrag | Performs a mouse drag and drop operation from the specified X1, Y1 coordinates to the specified Xn, Yn coordinates. |
Output | Retrieves the current value of an item and stores it in a specified location. |
PressKey | Presses the specified key and modifier in the object. |
RefreshObject | Instructs OpenText Functional Testing to re-identify the object in the application the next time a step refers to this object. |
Replace | Replaces text in specified boundaries with new text. |
Set | Sets the value of the edit box. |
SetCaretPos | Places the cursor in the specified location in an edit box. |
SetFocus | Sets the focus on the edit box. |
SetSecure | Sets the encrypted value of an edit box. |
SetSelection | Selects the specified text in the edit box. |
SetTOProperty | Sets the value of the specified description property in the test object description. |
ToString | Returns a string that represents the test object. |
Type | Types the specified text in the object. |
WaitProperty | Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step. |
Properties
Exist | Checks whether the object currently exists in the open application. |
Object | Accesses the native methods and properties of the object. |
Activate Method
Description
Activates the edit box.
Syntax
object.Activate
Return Type
None.
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the Activate method to activate the "Puzzle" edit box. Browser("Crossword").Page("Crossword").JavaApplet("Puzzle").JavaEdit("Puzzle").Activate
Click Method
Description
Clicks the specified location with the specified mouse button.
Syntax
object.Click (X, Y, [MouseButton])
Arguments
Parameter | Description |
---|---|
X |
Required. A Variant. The x-coordinate of the click. |
Y |
Required. A Variant. The y-coordinate of the click. |
MouseButton |
Optional. A String value. Indicates whether the click should be performed with the left or right mouse button. Possible values: "LEFT" (default) "RIGHT" Default value = "LEFT" |
Return Type
None.
IMPORTANT
You must enter valid x- and y-coordinates.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the Click method to click the Text: edit box at coordinates 5 and 5, using the 'left mouse button. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("Periodic").JavaEdit("Text:").Click 5, 5, "LEFT"
ClickLink Method
Description
Clicks the link with the specified name in the edit box.
Syntax
object.ClickLink (LinkText)
Arguments
Parameter | Description |
---|---|
LinkText |
Required. A Variant. The name of the link to click. |
Return Type
None
IMPORTANT
This method is not supported for JavaFX edit and text area objects.
Example
'The following example uses the ClickLink method to open all available links. Set LinkObj = Description.Create() LinkObj("html tag").Value = "A" 'Retrieves all link objects from the edit box and keeps them in the ChildLinkObj variable ChildLinkObj = Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("JEditorPane").ChildObjects(LinkObj) If ChildLinkObj <> 0 Then 'Runs in a loop over all links in the ChildLinkObj variable For i = 0 To ChildLinkObj.Count - 1 LinkName = ChildLinkObj(i).Value 'Clicks the link Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("JEditorPane").ClickLink LinkName Browser("Java Examples_2").Page("Java Examples").Sync 'Calls a function that confirms a match between the link name and the title of the page opened. VerifyPageCorrectness (LinkName) Browser("Java Examples_2").Back Next End If
CreateObject Method
Description
Creates an instance of any Java object within your application.
Syntax
object.CreateObject (ClassName, ConsArgs)
Arguments
Parameter | Description |
---|---|
ClassName |
Required. A String value. The Java class name. |
ConsArgs |
Required. None Any arguments required for the object's constructor. Enter the values in a comma separated list. If no arguments are required for the constructor, you do not need to supply a value for the ConsArgs argument. |
Return Type
A Variant.
Returns an object reference. You can use this reference to access the object's methods and properties, without using the Object property.
IMPORTANT
The class loader of the Java test object on which the CreateObject method is performed is used to load the class of the newly created Java object.
We recommend using the CreateObject method on a test object from the same toolkit as the object you want to create. For example, to create a Swing/JFC object, use the CreateObject method on an existing Swing/JFC Java test object.
For more information on the CreateObject method, and additional documentation on standard JDK classes, see the online Java API reference.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the CreateObject method to create a rectangle object. Set Rect = Browser("Periodic").Page("Periodic").JavaApplet("Periodic").JavaList("Panel").CreateObject("java.awt.Rectangle", 10, 20)
DblClick Method
Description
Double-clicks the specified location with the specified mouse button.
Syntax
object.DblClick (X, Y, [MouseButton])
Arguments
Parameter | Description |
---|---|
X |
Required. A Variant. The x coordinate of the location on the applet to be clicked. |
Y |
Required. A Variant. The y-coordinate of the location on the applet to be clicked. |
MouseButton |
Optional. A String value. Indicates whether the double-click should be performed with the left or right mouse button. Possible values: "LEFT" (default) "RIGHT" Default value = "LEFT" |
Return Type
None.
IMPORTANT
You must enter valid x- and y-coordinates.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the DblClick method to double-click the "Periodic JavaButton" object at 'coordinates 503 and 55, using the left mouse button. Browser("Periodic").Page("Periodic").JavaApplet("Periodic").JavaButton("Frame").DblClick 5, 5, "LEFT"
Delete Method
Description
Deletes the specified text.
Syntax
object.Delete (Row1, Col1, Row2, Col2)
Arguments
Parameter | Description |
---|---|
Row1 |
Required. A Variant. The row (top) location of the first character you want to delete. For single line edit boxes, enter 0. |
Col1 |
Required. A Variant. The column (left) location of the first character you want to delete. |
Row2 |
Required. A Variant. The row (bottom) location of the last character you want to delete. For single line edit boxes, enter 0. |
Col2 |
Required. A Variant. The column (right) location of the last character you want to delete. |
Return Type
None.
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the Delete method to delete selected text from an edit box. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Set "Some text line 1" + vbCrLf + "Some text line 2" + vbCrLf + "Some text line 3" RequiredText = "Some text line 1" + vbCrLf + "Some text line 2" + vbCrLf + "Some text line 3" InsertedText = Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").GetROProperty("value") If InsertedText = RequiredText Then 'confirms that edit has text in it Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Delete 0, 0, 2, 16 ' Delete the text Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty "value", "", 10 ' confirms that edit no longer has any text in it. Else Reporter.ReportEvent micFail, "Text insertion failed", "The required text was not inserted. Test cannot continue." ExitTest End If
FireEvent Method
Description
Simulates an event on a test object using one of several pre-defined event constants.
Syntax
object.FireEvent (EventType, EventArguments)
Arguments
Parameter | Description |
---|---|
EventType |
Required. A Numeric Value. Possible values: micMouseEnter, micMouseExit, micMouseClick, micMousePress, micMouseRelease, micMouseDrag, micMouseMove, micKeyPress, micKeyRelease, micKeyType, micFocusGain, micFocusLost. Note: The FireEvent method is supported only for java.awt.* components . The events for org.eclipse.swt.widgets.* controls are not supported. |
EventArguments |
Required. None Any parameters of the event's constructor except for the source and EventID. You can pass any Java constant that is used as one of the event’s constructor parameters using its string instead of its value. Enter the values in a comma separated list. If no additional parameters are required, you do not need to supply a value for the EventArguments argument. |
Return Type
None.
IMPORTANT
If the list of pre-defined constants does not cover the event you want to fire, you can use the FireEventEx method to fire any event that has a constructor.
This method is not supported for SWT-based controls.
This method is not recorded for text area objects in a JavaFX application.
For more information on the FireEvent method, and additional documentation on AWTEvents, MouseEvents, and KeyEvents, see the online Java API reference.
Example
'The following example uses the FireEvent method to fire a MouseClick event on the MySpinButton_0 JavaSpin. Browser("Browser").Page("Page").JavaApplet("mybuttonapplet").JavaSpin("MySpinButton_0").FireEvent micMouseClick, 0, "BUTTON1_MASK", 4, 4, 1, "OFF"
FireEventEx Method
Description
Simulates an event on a Java test object, given the ClassName, Event ID, and Event Parameters.
Syntax
object.FireEventEx (ClassName, EventId, EventArguments)
Arguments
Parameter | Description |
---|---|
ClassName |
Required. A String value. The name of the Java class representing the event to be activated. |
EventId |
Required. A String value. The event ID number or the final field string that represents the event ID. |
EventArguments |
Required. None Any parameters of the event's constructor except for the source and EventID. You can pass any Java constant that is used as one of the event’s constructor parameters using its string instead of its value. Enter the values in a comma separated list. If no additional parameters are required, you do not need to supply a value for the EventArguments argument. |
Return Type
None.
IMPORTANT
You can use FireEventEx for any Java event.
This method is not supported for SWT-based controls.
This method is not recorded for text area objects in a JavaFX application.
For more information on the FireEvent method, and additional documentation on AWTEvents, MouseEvents, and KeyEvents, see the online Java API reference.
Example
'The following example uses the FireEventEx method to fire a MouseClick event on the MyCheckBox_0 Java check box. Browser("Browser").Page("Page").JavaApplet("mybuttonapplet").JavaCheckBox("MyCheckBox_0").FireEventEx "java.awt.event.MouseEvent", "MOUSE_CLICKED", 0, "BUTTON1_MASK", 4, 4, 1, "False"
GetStatics Method
Description
Returns the Java object capable of accessing static members (methods and fields) of the specified Java class.
Syntax
object.GetStatics (ClassName)
Arguments
Parameter | Description |
---|---|
ClassName |
Required. A String value. The Java class name whose static members you want to access. |
Return Type
A Variant.
A reference to a Java object.
IMPORTANT
The class loader of the Java test object on which the GetStatics method is performed is used to load the class specified as a parameter of the GetStatics method.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the GetStatics method to retrieve the value of the 'out field of the java.lang.System class. Set OutStream = JavaWindow("Win").JavaRadioButton("SomeButton").GetStatics("java.lang.System").out
'The following example uses the GetStatics method to retrieve the object 'through which static members of the java.lang.System class can be accessed. 'It then uses this object to invoke the gc method of the .java.lang.System class, 'which runs the garbage collector on the application. Set SystemStatics = Browser("Browser").Page("Page").JavaApplet("mybuttonapplet.htm").JavaObject("MyButton").GetStatics("java.lang.System") SystemStatics.gc
'The following example uses the GetStatics method to print the "Hello, World!" string to the standard 'output, by using the static out field of the java.lang.System class. JavaWindow("Win").JavaEdit("Name").GetStatics("java.lang.System").out.println ("Hello, World!")
Insert Method
Description
Inserts a text string into the specified location in a edit box.
Syntax
object.Insert (str, Row, Column)
Arguments
Parameter | Description |
---|---|
str |
Required. A String value. The text string that you want to insert. |
Row |
Required. A Variant. The row that identifies the exact location where you want to insert the text string. For single line edit boxes, enter 0. |
Column |
Required. A Variant. The column that identifies the exact location where you want to insert the text string. |
Return Type
None.
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the Insert method to insert the text ",if you want," 'into the "Text:" edit box,in the "Periodic" applet. Browser("Browser").Page("Page").JavaApplet("Periodic").JavaEdit("Text:").Insert ",if you want,", 1, 20
'Uses the methods: SetFocus, SetCaret, SetSelection, Replace, and Insert to insert text into an edit box 'Sets the focus on a specific edit box to ensure it is activated for editing Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetFocus 'Sets caret position to initial state Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 0, 0 Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Insert "Some text line 1" + vbCrLf + "", 0, 0 'Puts the string into the RequiredText variable. RequiredText = "Some text line 1" + vbCrLf 'Verifies that the string was properly inserted into the text field If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty("value", RequiredText) Then 'Selects the text that was previously inserted Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetSelection 1, 0, 1, 16 'Copies the text to clipboard Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").PressKey "C", micCtrl 'Sets caret position for text replacement Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 1, 0 'Replaces the previously inserted text with the new one Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Replace 1, 0, 1, 15, "Newly inserted line" 'Inserts copied text to another text field Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").PressKey "V", micCtrl 'Checks that text for inserted properly Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").CheckProperty "value", "Some text line 1" End If
MouseDrag Method
Description
Performs a mouse drag and drop operation from the specified X1, Y1 coordinates to the specified Xn, Yn coordinates.
Syntax
object.MouseDrag (X1, Y1, X2, Y2, [MouseButton])
Arguments
Parameter | Description |
---|---|
X1 |
Required. A Variant. The x-coordinate of the location from which to begin the mouse drag. |
Y1 |
Required. A Variant. The y-coordinate of the location from which to begin the mouse drag. |
X2 |
Required. A Variant. The x-coordinate of the location where the mouse drag stops. |
Y2 |
Required. A Variant. The y-coordinate of the location where the mouse drag stops. |
MouseButton |
Optional. A String value. Indicates whether the click should be performed with the left or right mouse button. Possible values: "LEFT" (default) "RIGHT" Default value = "LEFT" |
Return Type
None.
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'##IS_EXAMPLE For="JAVAPACKAGELib~Setting~MouseDrag", Caption="Perform Mouse Drag and Drop Operations" 'The following example uses the MouseDrag method to perform a mouse drag and drop operation on a Java table object. Browser("Browser").Page("Page").JavaApplet("Periodic").JavaTable("Periodic").MouseDrag 4, 10, 10, 10, "LEFT"
PressKey Method
Description
Presses the specified key and modifier in the object.
Syntax
object.PressKey (Key, [Modifier])
Arguments
Parameter | Description |
---|---|
Key |
Required. A String value. micF1. Presses the F1 key. micF2. Presses the F2 key. micF3. Presses the F3 key. micF4. Presses the F4 key. micF5. Presses the F5 key. micF6. Presses the F6 key. micF7. Presses the F7 key. micF8. Presses the F8 key. micF9. Presses the F9 key. micF10. Presses the F10 key. micF11. Presses the F11 key. micF12. Presses the F12 key. micLeft. Presses the left arrow key. micRight. Presses the right arrow key. micDwn. Presses the down arrow key. micUp. Presses the up arrow key. micTab. Presses the TAB key. micReturn. Presses the RETURN or ENTER key. micBack. Presses the BACK key. micDel. Presses the DELETE key. micHome. Presses the HOME key. micEnd. Presses the END key. micEsc. Presses the ESC key. micPause. Presses the PAUSE key. micPrintScr. Presses the PRINT SCREEN key; supported for JavaFX only. micIns. Presses the INSERT key. |
Modifier |
Optional. A String value. The modifier(s) to use. Supported modifiers: micCtrl micAlt micShift micCtrlAlt micCtrlShift micCtrlShiftAlt micShiftAlt Default value = "" |
Return Type
None.
IMPORTANT
When typing keys during a recording session, OpenText Functional Testing records the PressKey method when one or more hot keys (such as F-keys, Alt, and Ctrl) are used.
It also records the PressKey method for any typed key in a Java object that supports text editing, but does not support the Set method.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example enters text in an edit box and then uses the PressKey method to cut the word 'edit' 'and paste it in a different location using the Ctrl-X and Ctrl-V shortcut keys. 'Place the cursor at the beginning of the text box. Browser("Java Examples").Page ("Java Examples") .Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").SetCaretPos 0, 0 'Enter a sentence in the text box. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field ").Set "Set the edit text." 'Select (highlight) the word 'edit'. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").SetSelection 0, 8, 0, 12 'Cut the word 'edit' Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").PressKey "X", micCtrl 'Place the cursor at the end of the text. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").SetCaretPos 0, 12 'Insert a space at the end of the text. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").Insert " ", 0, 12 'Paste the word 'edit' at the end of the text. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Text field").PressKey "V", micCtrl
Replace Method
Description
Replaces text in specified boundaries with new text.
Syntax
object.Replace (StartRow, StartCol, EndRow, EndCol, Text)
Arguments
Parameter | Description |
---|---|
StartRow |
Required. A Variant. The row that identifies the exact location on which you want to start replacing text. For single line edit boxes, enter 0 for row value. |
StartCol |
Required. A Variant. The column that identifies the exact location on which you want to start replacing text. |
EndRow |
Required. A Variant. The row that identifies the exact location on which you want to stop replacing text. For single line edit boxes, enter 0 for row value. |
EndCol |
Required. A Variant. The column that identifies the exact location on which you want to stop replacing text. |
Text |
Required. A String value. The new text that you want to insert. |
Return Type
None
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'Uses the methods: SetFocus, SetCaret, SetSelection, Replace, and Insert to insert text into an edit box 'Sets the focus on a specific edit box to ensure it is activated for editing Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetFocus 'Sets caret position to initial state Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 0, 0 Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Insert "Some text line 1" + vbCrLf + "", 0, 0 'Puts the string into the RequiredText variable. RequiredText = "Some text line 1" + vbCrLf 'Verifies that the string was properly inserted into the text field If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty("value", RequiredText) Then 'Selects the text that was previously inserted Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetSelection 1, 0, 1, 16 'Copies the text to clipboard Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").PressKey "C", micCtrl 'Sets caret position for text replacement Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 1, 0 'Replaces the previously inserted text with the new one Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Replace 1, 0, 1, 15, "Newly inserted line" 'Inserts copied text to another text field Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").PressKey "V", micCtrl 'Checks that text for inserted properly Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").CheckProperty "value", "Some text line 1" End If
'The following example uses the Replace method to replace the second to fifth characters in the first row 'of the "Frametitle:" edit field with the text lak. JavaWindow("SwingSet").JavaInternalFrame("Internal Frame").JavaEdit("Frame title:").Replace 0, 1, 0, 4, "lak"
Set Method
Description
Sets the value of the edit box.
Syntax
object.Set (Text)
Arguments
Parameter | Description |
---|---|
Text |
Required. A String value. The text to insert in the edit box. |
Return Type
None.
Examples
'The following example uses the SetSecure method to insert an encoded password string into a secured text box PassWord = "467fa6d4478c94c83925607fc1b6c6b39e39f98217ae" Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("Login").Set "Login" Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("JEditorPane").SetSecure (PassWord) Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaButton("Login").Click If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaStaticText("You've successfully logged into the system").Exist Then Reporter.ReportEvent micPass, " Secure login", "passed" Else Reporter.ReportEvent micPass, " Secure login", "failed" End If
JavaWindow("TextField Demo").JavaEdit("Login:").Set "Hello" + vbLf + "Hello World" = vbLf + ==
SetCaretPos Method
Description
Places the cursor in the specified location in an edit box.
Syntax
object.SetCaretPos (Row, Column)
Arguments
Parameter | Description |
---|---|
Row |
Required. A Variant. The row that identifies the exact location where you want to place the cursor within the edit box. For single line edit boxes, enter 0. |
Column |
Required. A Variant. The column that identifies the exact location where you want to place the cursor within the edit box. |
Return Type
None
IMPORTANT
This method is not recorded for text area objects in a JavaFX application.
Example
'Uses the methods: SetFocus, SetCaret, SetSelection, Replace, and Insert to insert text into an edit box 'Sets the focus on a specific edit box to ensure it is activated for editing Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetFocus 'Sets caret position to initial state Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 0, 0 Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Insert "Some text line 1" + vbCrLf + "", 0, 0 'Puts the string into the RequiredText variable. RequiredText = "Some text line 1" + vbCrLf 'Verifies that the string was properly inserted into the text field If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty("value", RequiredText) Then 'Selects the text that was previously inserted Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetSelection 1, 0, 1, 16 'Copies the text to clipboard Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").PressKey "C", micCtrl 'Sets caret position for text replacement Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 1, 0 'Replaces the previously inserted text with the new one Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Replace 1, 0, 1, 15, "Newly inserted line" 'Inserts copied text to another text field Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").PressKey "V", micCtrl 'Checks that text for inserted properly Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").CheckProperty "value", "Some text line 1" End If
'The following example uses the SetCaretPos method to position the cursor at the second character of the first 'row of the "Text:" edit box, in the "Periodic" applet. Browser("Browser").Page("Page").JavaApplet("Periodic").JavaEdit("Text:").SetCaretPos 0, 2
SetFocus Method
Description
Sets the focus on the edit box.
Syntax
object.SetFocus
Return Type
None.
IMPORTANT
If a Java application or applet does not handle these events, the method may not behave as expected.
This method is not recorded for text area objects in a JavaFX application.
Example
'Uses the methods: SetFocus, SetCaret, SetSelection, Replace, and Insert to insert text into an edit box 'Sets the focus on a specific edit box to ensure it is activated for editing Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetFocus 'Sets caret position to initial state Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 0, 0 Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Insert "Some text line 1" + vbCrLf + "", 0, 0 'Puts the string into the RequiredText variable. RequiredText = "Some text line 1" + vbCrLf 'Verifies that the string was properly inserted into the text field If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty("value", RequiredText) Then 'Selects the text that was previously inserted Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetSelection 1, 0, 1, 16 'Copies the text to clipboard Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").PressKey "C", micCtrl 'Sets caret position for text replacement Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 1, 0 'Replaces the previously inserted text with the new one Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Replace 1, 0, 1, 15, "Newly inserted line" 'Inserts copied text to another text field Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").PressKey "V", micCtrl 'Checks that text for inserted properly Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").CheckProperty "value", "Some text line 1" End If
'The following example uses the SetFocus method to set the focus on the "Text:" edit box. Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("Periodic").JavaEdit("Text:").SetFocus
SetSecure Method
Description
Sets the encrypted value of an edit box.
Syntax
object.SetSecure (EncryptedText)
Arguments
Parameter | Description |
---|---|
EncryptedText |
Required. A String value. The encrypted text to be entered in the edit box. |
Return Type
None.
IMPORTANT
To find the encoded value to use as the argument for the this method, do one of the following:
Use the Password Encoder utility (available from the Windows Start menu).
- Parameterize the argument using a Data Table parameter and use the Data Table encryption option (right-click each unencrypted value in the password column and choose Data > Encrypt).
For more information, refer to the OpenText Functional Testing User Guide.
While the SetSecure method enables you to hide passwords on the screen when running a test, it is not intended to be a secure way to protect password information.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the SetSecure method to enter an encrypted password in a password edit box. JavaWindow("DART Mail Login").JavaEdit("Email Address:").Set "MyName@company.com" JavaWindow("DART Mail Login").JavaEdit("Mail User Name:").Set "Myname" JavaWindow("DART Mail Login").JavaEdit("Mail Password:").SetSecure "424fe79992c06f8f77dd04e9cc8c73194a60" JavaWindow("DART Mail Login").JavaButton("Online").Click
'The following example uses the SetSecure method to insert an encoded password string into a secured text box PassWord = "467fa6d4478c94c83925607fc1b6c6b39e39f98217ae" Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("Login").Set "Login" Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaEdit("JEditorPane").SetSecure (PassWord) Browser("Java Examples_2").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaButton("Login").Click If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("SwingSet2Applet").JavaStaticText("You've successfully logged into the system").Exist Then Reporter.ReportEvent micPass, " Secure login", "passed" Else Reporter.ReportEvent micPass, " Secure login", "failed" End If
SetSelection Method
Description
Selects the specified text in the edit box.
Syntax
object.SetSelection (StartRow, StartCol, EndRow, EndCol)
Arguments
Parameter | Description |
---|---|
StartRow |
Required. A Variant. The row (top) location of the first character you want to select. |
StartCol |
Required. A Variant. The column (left) location of the first character you want to select. |
EndRow |
Required. A Variant. The row (bottom) location of the last character you want to select. |
EndCol |
Required. A Variant. The column (right) location of the last character you want to select. |
Return Type
None.
IMPORTANT
This is recorded when dragging the mouse and highlighting a text string, or by double-clicking a single word in the edit box.
Note: In a SingleLine edit box, you must use 0 as the RowStart and RowEnd arguments.This method is not recorded for text area objects in a JavaFX application.
Example
'Uses the methods: SetFocus, SetCaret, SetSelection, Replace, and Insert to insert text into an edit box 'Sets the focus on a specific edit box to ensure it is activated for editing Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetFocus 'Sets caret position to initial state Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 0, 0 Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Insert "Some text line 1" + vbCrLf + "", 0, 0 'Puts the string into the RequiredText variable. RequiredText = "Some text line 1" + vbCrLf 'Verifies that the string was properly inserted into the text field If Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").CheckProperty("value", RequiredText) Then 'Selects the text that was previously inserted Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetSelection 1, 0, 1, 16 'Copies the text to clipboard Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").PressKey "C", micCtrl 'Sets caret position for text replacement Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").SetCaretPos 1, 0 'Replaces the previously inserted text with the new one Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("very very very very very").Replace 1, 0, 1, 15, "Newly inserted line" 'Inserts copied text to another text field Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").PressKey "V", micCtrl 'Checks that text for inserted properly Browser("Java Examples").Page("Java Examples").Frame("MAIN").JavaApplet("TextAreaApplet").JavaEdit("Identical edit").CheckProperty "value", "Some text line 1" End If
Type Method
Description
Types the specified text in the object.
Syntax
object.Type (Text)
Arguments
Parameter | Description |
---|---|
Text |
Required. A String value. For additional supported keyboard presses, see PressKey method. |
Return Type
None.
IMPORTANT
This method is not recorded. (Keyboard operations are recorded using the Set or PressKey methods.) The Type method is useful for entering a combination of text and keyboard modifiers. You concatenate text strings and keyboard modifiers using the ampersand (&) symbol. For example, you can enter: Type "Hello World" & micCtrl & "S"
To add this method to your test, use the Step Generator or enter it manually in the Keyword View or Editor. For more information, see the Unified Functional Testing User Guide.
Note: Although the Type method is supported for most objects, if you enter a Type statement for an object in which a user cannot enter text, the method has no visual effect.
This method is not recorded for text area objects in a JavaFX application.
Example
'The following example uses the Type method to type ABC in a Java edit box. Browser("Periodic").Page("Periodic").JavaApplet("Periodic").JavaEdit("Text").Type "ABC"
See also: