Object Model Reference for GUI Testing > Java > Click Method

JavaToolbar Object

Description

A Java toolbar.

Operations

The sections below list the built-in methods and properties that you can use as operations for the JavaToolbar object.

Note: You can also view a list and descriptions of the JavaToolbar 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

Common Method CaptureBitmap Saves a screen capture of the object as a .png or .bmp image using the specified file name.
Common Method Check Checks whether the actual value of an item matches the expected value.
Common Method CheckProperty Checks whether the actual value of the specified object property matches the specified expected value within the specified timeout.
Common Method ChildObjects Returns the collection of child objects contained within the object.
Method Click Clicks the specified location with the specified mouse button.
Method CreateObject Creates an instance of any Java object within your application.
Method DblClick Double-clicks the specified location with the specified mouse button.
Method FireEvent Simulates an event on a test object using one of several pre-defined event constants.
Method FireEventEx Simulates an event on a Java test object, given the ClassName, Event ID, and Event Parameters.
Method GetContent Returns a string containing the names of all of the buttons in the toolbar.
Method GetItem Returns the name of the toolbar button specified by its index.
Method GetItemProperty Returns the current value of a property for a toolbar button.
Method GetItemsCount Returns the number of buttons in the toolbar.
Common Method GetROProperty Returns the current value of the description properties from the object in the application.
Method GetSelection

Returns a list of all the buttons in a toolbar that are pressed or checked.

Method GetStatics Returns the Java object capable of accessing static members (methods and fields) of the specified Java class.
Common Method GetTOProperties Returns the collection of properties and values used to identify the object.
Common Method GetTOProperty Returns the value of the specified description properties from the test object description.
Method MouseDrag Performs a mouse drag and drop operation from the specified X1, Y1 coordinates to the specified Xn, Yn coordinates.
Common Method Output Retrieves the current value of an item and stores it in a specified location.
Method Press Clicks the specified toolbar button.
Method PressKey Presses the specified key and modifier in the object.
Common Method RefreshObject Instructs UFT to re-identify the object in the application the next time a step refers to this object.
Common Method SetTOProperty Sets the value of the specified description properties in the test object description.
Method ShowDropdown Opens the dropdown menu associated with the specified toolbar button by clicking the arrow part of the button.
Common Method ToString Returns a string that represents the test object.
Method Type Types the specified text in the object.
Common Method WaitProperty Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.

Properties

Common Property Exist Checks whether the object currently exists in the open application.
Common Property Object Accesses the native methods and properties of the object.

 

Back to top

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.

Example


 

Back to top

CreateObject Method

Description

Creates an instance of any Java object within your application.

Syntax

object.CreateObject (ClassName)

Arguments

Parameter Description
ClassName Required. A String value.
The Java class name.
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

Example


 

Back to top

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.

Example


 

Back to top

FireEvent Method

Description

Simulates an event on a test object using one of several pre-defined event constants.

Syntax

object.FireEvent (EventType)

Arguments

Parameter Description
EventType Required. A tagJAVAEVENTTYPE Value.
The name of the pre-defined constant for the event you want to fire.
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

For more information on the FireEvent method, and additional documentation on AWTEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/AWTEvent.html

For additional documentation on MouseEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/event/MouseEvent.html

For additional documentation on KeyEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html

Example


 

Back to top

FireEventEx Method

Description

Simulates an event on a Java test object, given the ClassName, Event ID, and Event Parameters.

Syntax

object.FireEventEx (ClassName, EventId)

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.
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

For more information on the FireEventEx method, and additional documentation on AWTEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/AWTEvent.html

For additional documentation on MouseEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/event/MouseEvent.html

For additional documentation on KeyEvents, see:

http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html

Example


 

Back to top

GetContent Method

Description

Returns a string containing the names of all of the buttons in the toolbar.

Syntax

object.GetContent

Return Type

A String value.

The returned string contains all of the items in the toolbar separated by a semicolon (;).

Example


 

Back to top

GetItem Method

Description

Returns the name of the toolbar button specified by its index.

Syntax

object.GetItem (Item)

Arguments

Parameter Description
Item Required. A Variant.
Numeric index of the button (without quotes or in the format "#N"). Index values begin with 1.

Return Type

A String value.

Example


 

Back to top

GetItemProperty Method

Description

Returns the current value of a property for a toolbar button.

Syntax

object.GetItemProperty (Item, Property)

Arguments

Parameter Description
Item Required. A Variant.
Label of the toolbar button in the toolbar or its numeric index (without quotes or in the format "#N"). Index values begin with 1.
Property Required. A String value.
Property to retrieve from the toolbar button. The following properties are supported: 
Property Name
Description
enabled
Indicates whether the toolbar button is enabled (accepts user input).
Possible values:                                    
       True
       False
index
The index number of the toolbar button. The index does not include hidden and separator buttons.
Values begin with 1.
name
The name of the toolbar button.
selected
Indicates whether the toolbar button is currently either pressed (currently being clicked) or checked (a dual-state push button that is currently selected).
Possible values:                                    
       True
       False

 

Return Type

A String value.

Example


 

Back to top

GetItemsCount Method

Description

Returns the number of buttons in the toolbar.

Syntax

object.GetItemsCount

Return Type

A long integer value.

Example


 

Back to top

GetSelection Method

Description

Returns a list of all the buttons in a toolbar that are pressed or checked.

Syntax

object.GetSelection

Return Type

All of the selected items in the toolbar separated by a semicolon (;).

Example


 

Back to top

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.

Example


 

Back to top

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.

Example


 

Back to top

Press Method

Description

Clicks the specified toolbar button.

Syntax

object.Press (Item)

Arguments

Parameter Description
Item Required. A Variant.
The toolbar button to press. The button label (with quotes) or numeric index (without quotes or in the format "#N") can denote the button. The name reflects the button's attached text (tooltip). The index of the first button in the toolbar is 1.

Return Type

None.

IMPORTANT

When recording operations on toolbar buttons, UFT records the button label value for the Item argument if the label has a value and that value is unique in the toolbar.  Otherwise UFT records the button index.

Example


 

Back to top

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.
The keyboard key(s) to press. If you want to press a function key (F1-F12), use a constant from the following list:
Constant
Action
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.

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, UFT records the PressKey method when one or more hot keys (such as F-keys, Alt, Ctrl, and so on) 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.

Example


 

Back to top

ShowDropdown Method

Description

Opens the dropdown menu associated with the specified toolbar button by clicking the arrow part of the button.

Syntax

object.ShowDropdown (Item)

Arguments

Parameter Description
Item Required. A Variant.
The toolbar button for which you want to show the drop-down item. The button label (with quotes) or numeric index (without quotes or in the format "#N") can denote the button. The index of the first button in the toolbar is numbered 1.

Return Type

None.

Example


 

Back to top

Type Method

Description

Types the specified text in the object.

Syntax

object.Type (Text)

Arguments

Parameter Description
Text Required. A String value.
The text to type and/or the modifier(s) to press.
Supported modifiers:
micAlt
micShift
micCtrlAlt
micCtrlShift
micCtrlShiftAlt
micShiftAlt

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.

Example


Back to top

See also: