WebTree Object
Description
A tree control in a Web site or application
IMPORTANT
- There may be test performance issues with this object, especially on Internet Explorer browsers.
- This object is not supported on Microsoft Edge browsers.
Operations
The sections below list the built-in methods and properties that you can use as operations for the WebTree object.
Note: You can also view a list and descriptions of the WebTree 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
CaptureBitmap | Saves a screen capture of the object as a .png or .bmp image, depending on the specified file extension. |
Check | Checks whether the actual value of an item matches the expected value. |
CheckProperty | Checks whether the specified object property achieves the specified 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 object. |
Collapse | Collapse the tree to a specific item based on the specified path. |
DoubleClick | Clicks on the object twice. |
Drag | Performs the 'drag' part of a drag and drop operation. |
Drop | Performs the 'drop' part of a drag and drop operation. |
Expand | Expand the tree to a specific item based on the specified path. |
FireEvent | Triggers an event. |
GetROProperty | Returns the current value of the specified description property from the object in the application. |
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. |
HoverTap | When hover is supported, places the pointer on the object. Otherwise, taps the object. |
LongPress | Presses and holds the object. |
MiddleClick | Middle-clicks the object. |
Output | Retrieves the current value of an item and stores it in a specified location. |
Pan | Perform a pan gesture. |
Pinch | Perform a pinch gesture. |
RefreshObject | Instructs UFT One to re-identify the object in the application the next time a step refers to this object. |
RightClick | Right-clicks the object. |
Select | Select an item in the tree. |
SetTOProperty | Sets the value of the specified description property in the test object description. |
Submit | Submits a form. |
Swipe | Swipes the object. |
ToString | Returns a string that represents the current test 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. |
Click Method
Description
Clicks the object.
Syntax
object.Click [x], [y], [button]
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate of the click. The specified coordinates are relative to the upper left corner of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
button |
Optional. A predefined constant or number. The mouse button used to click the object. Default value = micLeftBtn |
Return Type
None
IMPORTANT
- UFT One does not record the Click method for right- or middle-clicks. Instead, UFT One records the RightClick and MiddleClick methods.
Example
'The following example uses the Click method on a form. Browser("New Page").Page("New Page").WebElement("html tag:=Form").Click
Collapse Method
Description
Collapse the tree to a specific item based on the specified path.
Syntax
object.Collapse (itemPath, [XPathToOpener] [doDblClickOnOpener)
Arguments
Parameter | Description |
---|---|
itemPath |
Required. A String value. The item to collapse. The value can either be one of the items in the list or an index. To specify the index of the item to select, use "#N". Index values begin with 0. |
XPathToOpener |
Optional. A String value. The path to the node which collapses the tree item, relative to the tree item root element. For example, if you trying to expand/collapse a node that does not work:
When you are done, the test step is WebTree.Collapse "node A; node B", "IMG[1]". Default value = "" |
doDblClickOnOpener | Optional. A string value. Instructs UFT One to open a tree element with a double click. Possible values:
This parameter is ignored for Firefox and Chrome browsers./ |
Return Type
None.
IMPORTANT
- This test object method may be recorded incorrectly as a .Select method. If this happens, you need to manually change the method to the Collapse method after recording.
- There may be a slight delay when using this step due to the animation of the collapse/expand operation. You should add a Wait statement after Collapse method steps to wait for this animation.
Example
'The following example collapse a WebTree object by referencing a specific 'item in the tree. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Collapse "My Web Site;images"
'The following example collapses a tree by accessing the XPath of 'the tree element. 'You should use the XPath argument when the itemPath argument does not collapse the tree correctly. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Collapse "My Web Site;images","DIV[1]/SPAN[1]"
DoubleClick Method
Description
Clicks on the object twice.
Syntax
object.DoubleClick ([interval], [x], [y])
Arguments
Parameter | Description |
---|---|
interval |
Optional. A double floating value. The number of seconds between the two clicks. The default value is 0.2 seconds. |
x |
Optional. A long integer value. The x-coordinate of the click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None.
IMPORTANT
- This method is supported as long as the Web site being tested is run on a mobile device on Digital Lab (UFT Mobile), and the test object implements this gesture. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
- If you are testing a web or hybrid application on a mobile device, this method is equivalent to performing the DoubleTap gesture.
Example
'The following example uses the DoubleClick method on a form. Browser("New Page").Page("New Page").WebElement("html tag:=Form").DoubleClick
Drag Method
Description
Performs the 'drag' part of a drag and drop operation.
Syntax
object.Drag [x], [y], [button], [Modifier]
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate within the source object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate within the source object. Default value = -9999 |
button |
Optional. A predefined constant or number. The mouse button used to drag the object. (Releasing the button performs the Drop operation.) Default value = micLeftBtn |
Modifier |
Optional. A String value. The keyboard modifier that is pressed during the Drag operation. Possible values:
Default value = 0 |
Return Type
None
IMPORTANT
Drag and Drop operations are performed as a coupled step. Inserting one operation without the other causes an error to occur in the run session.
This test object method is not supported on Safari browsers.
UFT One supports the following scenarios:
- Scenario A: One object is dragged onto another object. For example, you can drag a WebButton from one frame object (source object) to another object (target objects), or drag a WebElement (source object) onto a Link object (target object) in the same frame.
- Scenario B: An object is moved from one location in a frame to another location in the same frame. In this case, the test object used for the Drag step is the same as the test object used for the Drop step.
- Scenario C: An item within an object is moved to another location within that object (also known as drag and pan). For example, in a map application, you can relocate an image relative to itself or drag a Slider object.
General Note:
UFT One always runs Drag and Drop steps using the mouse API, even if you defined the Replay type as Event in the Run Settings node of the Web > Advanced pane of the Options dialog box (Tools > Options > GUI Testing tab > Web > Advanced node).
Notes for Scenario A:
- When recording: You cannot record cross-object or cross-frame types of drag and drop operations (operations in which you try to drop and object on another object or in another frame). You can, however, insert these types of Drop steps manually. Note that it may be helpful to record a Drag and Drop operation on the object in order to determine valid coordinates for the Drag operation step. You need to delete the recorded Drop step, though, and manually add a new Drop step for the target object instead.
- When running. If the application being tested supports scrolling, then UFT One supports scrolling when the Drag and Drop test objects are both located in the same frame. UFT One drags the Drag object ot the edge of the frame, waits for the Drop object to appear, and drops the Drag object onto the Drop object. If the application being tested does not support scrolling, then UFT One displays an error message when it reaches a step that requires scrolling.
- When running. If you want to drag a test object from one frame to another, UFT One tries to make both the Drag and Drop objects visible in their frames prior to performing the Drag and Drop operation. If the two objects cannot be viewed simultaneously (for example, because the browser window is too small), the step fails.
Notes for Scenario B and C:
- If the screen resolution during a run session is not the same as the screen resolution during the recording session, then the size of the frame may be different during the run session as compared to the recording session. In this case, the target location coordinates may be different during the run session and this may cause the test steps to fail.
- During a run session, if the coordinates of a Drop
Example
'The following example uses the Drag and Drop methods to drag a copy of an item from the Inbox pane of 'Microsoft Outlook Web Access and drop it in the Junk folder. Then it uses the Drag and Drop methods again 'to move the item from the Junk folder to the Deleted Items folder. Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").Drag , micNoCoordinate, micNoCoordinate, micCtrl Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Junk E-mail").Drop Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").Drag Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Deleted Items").Drop
Drop Method
Description
Performs the 'drop' part of a drag and drop operation.
Syntax
object.Drop [x], [y]
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate of the target object on which the dragged object is dropped. If the dragged and dropped object is the same object, then the x-coordinate is relative to the upper left corner in the source location prior to being dragged. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the target object on which the dragged object is dropped. If the dragged and dropped object is the same object, then the y-coordinate is relative to the upper left corner in the source location prior to being dragged. Default value = -9999 |
Return Type
None
IMPORTANT
- Drag and Drop operations are performed as a coupled step. Inserting one operation without the other causes an error to occur. For more details on Drag and Drop operations, see Drag Method.
- This test object method is not supported on Safari browsers.
Example
'The following example uses the Drag and Drop methods to drag a copy of an item from the Inbox pane of 'Microsoft Outlook Web Access and drop it in the Junk folder. Then it uses the Drag and Drop methods again 'to move the item from the Junk folder to the Deleted Items folder. Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").Drag , micNoCoordinate, micNoCoordinate, micCtrl Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Junk E-mail").Drop Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").Drag Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Deleted Items").Drop
Expand Method
Description
Expand the tree to a specific item based on the specified path.
Syntax
object.Expand (itemPath, [XPathToOpener], [doDblClickOnOpener)
Arguments
Parameter | Description |
---|---|
itemPath |
Required. A String value. The path to the node which expands the tree item, relative to the tree item root element. The path can be a semicolon delimited list of tree items. The values can either be one of the items in the list or an index. To specify the index of the item to select, use "#N". Index values begin with 0. |
XPathToOpener |
Optional. A String value. The path to the node which expands the tree item, relative to the tree item root element. For example, if you trying to expand/collapse a node that does not work when using name path:
When you are done, the test step is WebTree.Expand "node A; node B", "IMG[1]".
Default value = "" |
doDblClickOnOpener | Optional. A string value. Instructs UFT One to open a tree element with a double click. Possible values:
This parameter is ignored for Firefox and Chrome browsers./ |
Return Type
None.
IMPORTANT
- This test object method may be recorded incorrectly as a .Select method. If this happens, you need to manually change the method to the Expand method after recording.
- There may be a slight delay when using this step due to the animation of the collapse/expand operation. You should add a Wait statement after Collapse method steps to wait for this animation.
Example
'The following example expands a tree by accessing a specific item 'in the tree element. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Expand "My Web Site;images"
'The following example expands a tree by accessing the XPath of 'the tree element. 'You should use the XPath argument when the itemPath argument does not expand the tree correctly. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Expand "My Web Site;images","DIV[1]/SPAN[1]"
FireEvent Method
Description
Triggers an event.
Syntax
object.FireEvent EventName, [x], [y], [button]
Arguments
Parameter | Description |
---|---|
EventName |
Required. A String value. The name of the event to trigger. Available events include: onchange, onclick, ondblclick, onblur, onfocus, onmousedown, onmouseup, onmouseover, onmouseout, onsubmit, onreset, and onpropertychange. |
x |
Optional. A long integer value. The x-coordinate, relative to the upper left corner of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate, relative to the upper left corner of the object. Default value = -9999 |
button |
Optional. A predefined constant or number. The mouse button used to fire the object. Default value = micLeftBtn |
Return Type
None
Example
'The following example uses the FireEvent method to trigger 'the onpropertychange event on a form. Browser("New Page").Page("New Page").WebElement("html tag:=Form").FireEvent "onpropertychange"
HoverTap Method
Description
When hover is supported, places the pointer on the object. Otherwise, taps the object.
Syntax
object.HoverTap ([x], [y])
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate of the hover point or tap. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the hover point or tap. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None.
IMPORTANT
This method is supported as long as the application supports touch events and is run on a mobile device on Digital Lab (UFT Mobile) or a touch-enabled browser. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
Example
'When performed in an environment that supports hovering, such as a desktop browser, 'the following example hovers over the checkbox, perhaps displaying a tooltip. 'When performed in an environment that does not support hovering, such as a mobile 'browser, the example taps the checkbox instead, perhaps selecting it. Browser("Mercury Tours").Page("Find Flights").WebCheckBox("roundtrip").HoverTap
LongPress Method
Description
Presses and holds the object.
Syntax
object.LongPress [duration], [x], [y]
Arguments
Parameter | Description |
---|---|
duration |
Optional. A double floating value. The time period (in seconds) to hold the long tap gesture. You can specify partial seconds as a duration time. Default value = 1 |
x |
Optional. A long integer value. The x-coordinate of the long press gesture. The coordinate is relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the object. The coordinate is relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None
IMPORTANT
This method is supported as long as the application supports touch events and is run on a mobile device on Digital Lab (UFT Mobile) or a touch-enabled browser. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
MiddleClick Method
Description
Middle-clicks the object.
Syntax
object.MiddleClick [x], [y]
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate of the middle-click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the middle-click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None
IMPORTANT
- If UFT One does not record the MiddleClick method, it may be due to Web Event Recording Configuration settings that were preserved from the upgrade of a previous UFT One version. In this case, you can enable recording of these methods by resetting the Web Event Recording Configuration to a preconfigured level. For details, see the topic on the Custom Web Event Recording Configuration in the Add-ins section of the UFT One Help Center.
- When Event replay is selected for the Replay type option in the Web > Advanced pane of the Options dialog box (Tools > Options > GUI Testing tab > Web > Advanced node), UFT One fires onmousedown, focus, and onmouseup events for this method, which may cause slightly different behavior than the regular Click method with a micMiddleButton value for the Button argument.
Pan Method
Description
Perform a pan gesture.
Syntax
object.Pan (deltaX, deltaY, [duration], [startX], [startY])
Arguments
Parameter | Description |
---|---|
deltaX |
Required. A long integer value. The distance moved on the x-axis, relative to the starting point. |
deltaY |
Required. A long integer value. The distance moved on the y-axis, relative to the starting point. |
duration |
Optional. A double floating value. The number of seconds required to perform the pan gesture. Default value = 0.5 |
startX |
Optional. A long integer value. The x-coordinate of where the pan gesture starts. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
startY |
Optional. A long integer value. The y-coordinate of where the pan gesture starts. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None.
IMPORTANT
This method is supported as long as the Web site being tested is run on a mobile device on Digital Lab (UFT Mobile), and the test object implements this gesture. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
This method is not supported on Internet Explorer and older versions of Firefox.
Example
'The following example performs a Pan gesture on a Google Maps web page, panning diagonally to the bottom right. Device("Device").App("MC Browser").MobileWebView("Web View").Page("Google Maps").WebElement("WebElement").Pan 564, 507
Pinch Method
Description
Perform a pinch gesture.
Syntax
object.Pinch (scale, [duration], [x], [y])
Arguments
Parameter | Description |
---|---|
scale |
Required. A double floating value. The zoom scale resulting in the pinch gesture. This is the ration between the distance between the fingers at the end of the pinch gesture to the distance between the fingers at the beginning of the pinch gesture. |
duration |
Optional. A double floating value. The number of seconds required to perform the pinch gesture. Default value = 1 |
x |
Optional. A long integer value. The x-coordinate of where the pinch gesture begins. The specified coordinates are relative ot the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of where the pinch gesture begins. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None.
IMPORTANT
This method is supported as long as the Web site being tested is run on a mobile device on Digital Lab (UFT Mobile), and the test object implements this gesture. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
This method is not supported in Internet Explorer and older versions of Firefox.
Example
'The following example performs a Pinch gesture on a Google Maps web page, where the zoom is multiplied by 2.5. Device("Device").App("MC Browser").MobileWebView("Web View").Page("Google Maps").WebElement("WebElement").Pinch 2.5
RightClick Method
Description
Right-clicks the object.
Syntax
object.RightClick [x], [y]
Arguments
Parameter | Description |
---|---|
x |
Optional. A long integer value. The x-coordinate of the right-click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
y |
Optional. A long integer value. The y-coordinate of the right-click. The specified coordinates are relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None
IMPORTANT
- If UFT One does not record the RightClick method, it may be due to Web Event Recording Configuration settings that were preserved from the upgrade of a previous UFT One version. In this case, you can enable recording of this method by resetting the Web Event Recording Configuration to a preconfigured level. For details, see the topic on the Custom Web Event Recording Configuration in the Add-ins section of the UFT One Help Center.
- When Event Replay is selected for the Replay type option in the Web > Advanced pane of the Options dialog box (Tools > Options > GUI Testing tab > Web > Advanced node), UFT One fires onmousedown, focus, onmouseup, and oncontextmenu events for this method, which may cause slightly different behavior than the regular Click method with a micRightButton value for the Button argument.
Select Method
Description
Select an item in the tree.
Syntax
object.Select (itemPath, [XPathToSelector], [XPathToOpener], [doDblClickOnOpener)
Arguments
Parameter | Description |
---|---|
itemPath |
Required. A String value. A semicolon delimited list of nodes in the path. The values in the path can either be a name of an item in the list or an index. To specify the index of the item to select, use "#N". Index values begin with 0. |
XPathToSelector |
Optional. A String value. The path for the selected part of the tree item, relative to the expander tree item element. If you do not need this argument, leave it is an empty value "", but still specify the XPathToOpener argument. Default value = "" |
XPathToOpener |
Optional. A String value. The path for the expander part of the tree item, relative to the tree item element. For example, if you trying to expand/collapse a node that does not work:
When you are done, the test step is WebTree.Select "node A; node B", "", "IMG[1]". Default value = "" |
doDblClickOnOpener | Optional. A string value. Instructs UFT One to open a tree element with a double click. Possible values:
This parameter is ignored for Firefox and Chrome browsers./ |
Return Type
None.
Example
'The following example selects an item in a WebTree by accessing a 'specific item in the tree. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Select "My Web Site;images;body-back.png"
'The following example selects an item in a WebTree object using the 'element's XPath value. 'The XPath value should be used when the regular itemPath argument value is not 'selecting the item correctly. Browser("Change Services").Page("Kendo UI TreeView widget").WebTree("treeview").Select "My Web Site;images;body-back.png", “DIV[1]/SPAN[1]/SPAN[1]”,"DIV[1]/SPAN[1”
Submit Method
Description
Submits a form.
Syntax
object.Submit
Return Type
None.
IMPORTANT
This method simulates pressing the Enter key, while the focus is on the object specified in the statement.
If the object is not part of a Web form, the Submit method has no effect.
Swipe Method
Description
Swipes the object.
Syntax
object.Swipe direction, [distance], [duration], [startX], [startY]
Arguments
Parameter | Description |
---|---|
direction |
Required. A MoveDirection Value. The direction of the swipe gesture. Possible values:
|
distance |
Optional. A long integer value. The distance (in pixels) of the swipe gesture. Default value = 200 |
duration |
Optional. A double floating value. The time period (in seconds) of the swipe gesture. You can specify partial seconds as a duration time. Default value = 0.25 |
startX |
Optional. A long integer value. The x-coordinate at which the swipe gesture begins. The specified coordinates are relative ot the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
startY |
Optional. A long integer value. The y-coordinate at which the swipe gesture begins. The coordinate is relative to the upper left corner of the object. The default value is the center of the object. Default value = -9999 |
Return Type
None
IMPORTANT
This method is supported as long as the application supports touch events and is run on a mobile device on Digital Lab (UFT Mobile) or a touch-enabled browser. Using this method on desktop browsers may generate warnings, even if you are using a mobile emulator.
This method is not supported in Internet Explorer or older versions of Firefox.
This method is not supported on Windows Phone.
Example
'The following example performs a Swipe gesture on a Google Maps web page, swiping left. Device("Device").App("MC Browser").MobileWebView("Web View").Page("Google Maps").WebElement("WebElement").Swipe moveLeft, 200
See also: