public class RootTestObject extends ClientTestObject
RootTestObject represents a global view of the system being tested.
It does not represent an actual TestObject in the software under test,
but rather it provides access to system-wide functionality, such as
finding an arbitrary TestObject based on properties, location, or getting the
DomainTestObject.ignoreTheObjectState, ref| Modifier and Type | Method and Description |
|---|---|
void |
emitLowLevelEvent(LowLevelEvent event)
Plays back a low level event.
|
void |
emitLowLevelEvent(LowLevelEvent[] events)
Plays back a sequence of low level events.
|
boolean |
enableForTesting(int processId)
Enables the process with
processId for testing. |
boolean |
enableForTesting(long windowHandle)
Enables the process with window
windowHandle for testing. |
boolean |
enableForTesting(java.lang.String processName)
Enables the process(es) with name
processName for testing. |
boolean |
exists()
The
RootTestObject is always available. |
TestObject |
find()
Finds the object in the software under test and returns a reference to it.
|
TestObject[] |
find(Subitem properties)
Finds all candidates that match given search criteria.
|
TestObject[] |
find(Subitem properties,
boolean mappableOnly)
Finds all candidates that match the given search criteria.
|
java.lang.String |
getDescriptiveName()
Returns the descriptive name of the object in software under test.
|
DomainTestObject[] |
getDomains()
Returns an array of all the domains that can be tested in the system.
|
TestObject[] |
getOwnedObjects()
Returns null as owned objects are not applicable for RootTestObject
|
TestObject |
getOwner()
returns null as the RootTestObject does not have any owner.
|
TestObject |
getParent()
Returns a reference to the parent object.
|
static java.lang.String |
getPid() |
java.util.Hashtable |
getProperties()
Returns null , as no properties available for the RootTestObject
|
static RootTestObject |
getRootTestObject()
Gets the
RootTestObject. |
IScreen |
getScreen()
Returns an interface to the screen object.
|
java.awt.image.BufferedImage |
getScreenSnapshot()
Takes a snapshot (screen capture) of the entire desktop
|
java.awt.image.BufferedImage |
getScreenSnapshot(java.awt.Rectangle rect)
Takes a snapshot (screen capture) of the specified portion of the desktop
|
java.awt.image.BufferedImage |
getScreenSnapshot(java.awt.Rectangle rect,
boolean clipToVisibleArea)
Takes a snapshot (screen capture) of the specified portion of the desktop *
|
java.awt.image.BufferedImage |
getScreenSnapshot(java.awt.Rectangle rect,
java.lang.String fname)
Takes a snapshot (screen capture) of the specified portion of the desktop
If a custom imaging solution is provided, a temporary file name with full
path should be passed.
|
static ScreenTestObject |
getScreenTestObject() |
IWindow[] |
getTopWindows()
Returns an array of
IWindows. |
boolean |
isMappedObject()
Returns
true if the object contains a mapped reference. |
GuiTestObject |
objectAtPoint(java.awt.Point screenPt)
Returns a
GuiTestObject for the object at the specified screen location. |
exists, exists, findAndInvoke, findAndInvokeProxy, getProperty, getTestDataTypes, invoke, invokeProxy, unregister, waitForExistencecompare, compare, compareAndLog, compareAndLog, equals, findAndInvoke, getActualData, getChildren, getDescribedObject, getDescribedObjects, getDomain, getField, getIndexer, getIndexer, getIndexers, getMappableChildren, getMappableParent, getMapProperties, getMethods, getNameInScript, getNonValueProperties, getObjectClassName, getObjectCustomClassName, getObjectReference, getProcess, getPropertyFromMap, getRecognitionProperties, getRecognitionPropertyWeight, getScriptCommandFlags, getStandardProperties, getTestData, getTopMappableParent, getTopParent, hashCode, invoke, invoke, invoke, invokeProxy, invokeProxy, isHtmlWebui, isLoggedDuringUnregister, isSameObject, isScreenTestObject, isTopLevelTestObject, performTest, performTest, performTest, performTest, setIndexer, setIndexer, setLoggedDuringUnregister, setMapProperties, setProperty, toString, updateTestData, waitForExistencepublic static RootTestObject getRootTestObject()
RootTestObject.public static ScreenTestObject getScreenTestObject()
public boolean exists()
RootTestObject is always available. This method always
returns true.exists in class ClientTestObjectClientTestObjectpublic GuiTestObject objectAtPoint(java.awt.Point screenPt)
GuiTestObject for the object at the specified screen location.public IScreen getScreen()
public IWindow[] getTopWindows()
IWindows. The IWIndow interface provides access to the native
windowing layer. This method is never recorded.
Any script that uses this method will likely be platform specific.
If there are no top windows (an unlikely situation), a zero-length array is returned.public DomainTestObject[] getDomains()
public boolean isMappedObject()
TestObjecttrue if the object contains a mapped reference.
Returns false for a TestObject that is returned by
reference from the software under test.isMappedObject in class TestObjectpublic java.lang.String getDescriptiveName()
TestObjectgetDescriptiveName in class TestObjectpublic TestObject getParent()
TestObjectTestObject
and support more methods. Therefore, you may want to cast the return value.
The reference to the object should be
released by calling one of the unregister methods.public TestObject[] getOwnedObjects()
public java.util.Hashtable getProperties()
getProperties in class TestObjectpublic TestObject getOwner()
getOwner in class TestObjectTestObject.getOwnedObjects(),
TestObject.getParent(),
TestObject.getChildren(),
TestObject.getMappableParent(),
TestObject.getMappableChildren(),
TestObject.unregister(),
RationalTestScript.unregister(Object[]),
RationalTestScript.unregisterAll(),
RationalTestScript.getRegisteredTestObjects()public static java.lang.String getPid()
public TestObject find()
ClientTestObjectpublic TestObject[] find(Subitem properties)
atProperty- A name/value pair representing a TestObject property.atChild- Contains one or more properties that must be matched
against the direct child of the starting TestObject.atDescendant- Contains one or more properties that can be matched
against any child of the starting TestObject.atList- Used to specify a sequential list of properties to match against.
Subitems that are valide for atList are:
atChildatDescendantatPropertyRootTestObject find, including:
.processName- As a top-level property this has two functions:
.processId- As a top-level property this has two functions:
.domain- Only search in top-level domains matching the .domain property..hWnd- along with the hWnd property being used for the search, if the .domain
"Win" is also specified the matching window will be enabled for testing.Handle- along with the window handle property being used for the search, if the .domain
"Net" is also specified the matching window will be enabled for testing.
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// This finds all top-level windows in the Windows domain with caption "My Document".
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption", caption)) ;
// This finds any dialogs and returns their children "OK" buttons.
RegularExpression dialogRE = new RegularExpression("*dialog", false) ;
RegularExpression buttonRE = new RegularExpression("*button", false) ;
foundTOs = root.find(atList(
atDescendant(".class", dialogRE),
atChild(".class", buttonRE, ".value", "OK"))) ;
// This starts Notepad, dynamically enables that process, finds its toplevel window that
// matches the process id, and gets its descendant text window.
ProcessTestObject p1 = StartApp("Notepad") ;
Integer pid = new Integer((int)p1.getProcessId()) ;
foundTOs = root.find(atList(
atProperty(".processId", pid,
atDescendant(".class", ".text"))) ;
// This enables a Windows app with the provided window handle and returns a
// TestObject representing the window.
Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));
// This enables a .NET app with the provided window handle and returns a
// TestObject representing the window.
Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));
find in class TestObjectproperties - The property set to match against.ClientTestObject.unregister(),
RationalTestScript.unregister(Object[]),
RationalTestScript.unregisterAll(),
RationalTestScript.getRegisteredTestObjects()public TestObject[] find(Subitem properties, boolean mappableOnly)
atProperty- A name/value pair representing a TestObject property.atChild- Contains one or more properties that must be matched
against the direct child of the starting TestObject.atDescendant- Contains one or more properties that can be matched
against any child of the starting TestObject.atList- Used to specify a sequential list of properties to match against.
Subitems that are valide for atList are:
atChildatDescendantatPropertyRootTestObject find, including:
.processName- As a top-level property this has two functions:
.processId- As a top-level property this has two functions:
.domain- Only search in top-level domains matching the .domain property..hWnd- along with the hWnd property being used for the search, if the .domain
"Win" is also specified the matching window will be enabled for testing.Handle- along with the window handle property being used for the search, if the .domain
"Net" is also specified the matching window will be enabled for testing.
TestObject[] foundTOs ;
RootTestObject root = RootTestObject.getRootTestObject() ;
// This will find all toplevel windows in the Windows domain with caption "My Document"
CaptionText caption = new CaptionText("My Document") ;
foundTOs = root.find(atChild(".domain", "Win", ".caption", caption)) ;
// This will find any dialogs, then return their children "OK" buttons.
RegularExpression dialogRE = new RegularExpression("*dialog", false) ;
RegularExpression buttonRE = new RegularExpression("*button", false) ;
foundTOs = root.find(atList(
atDescendant(".class", dialogRE),
atChild(".class", buttonRE, ".value", "OK"))) ;
// This will start Notepad, dynamically enable that process, find its toplevel window that
// matches the process id and get its descendant text window.
ProcessTestObject p1 = StartApp("Notepad") ;
Integer pid = new Integer((int)p1.getProcessId()) ;
foundTOs = root.find(atList(
atProperty(".processId", pid,
atDescendant(".class", ".text"))) ;
// This enables a Windows app with the provided window handle and returns a
// TestObject representing the window.
Long hWnd = getAppsHwnd();
foundTOs = root.find(atChild(".hwnd", hWnd, ".domain", "Win"));
// This enables a .NET app with the provided window handle and returns a
// TestObject representing the window.
Long handle = getAppsHwnd();
foundTOs = root.find(atChild("Handle", handle, ".domain", "Net"));
find in class ClientTestObjectproperties - The property set to match against.mappableOnly - Whether to search all children or just mappable childrenClientTestObject.unregister(),
RationalTestScript.unregister(Object[]),
RationalTestScript.unregisterAll(),
RationalTestScript.getRegisteredTestObjects()public boolean enableForTesting(java.lang.String processName)
processName for testing.processName - the name of the process(es) to enable.public boolean enableForTesting(int processId)
processId for testing.processId - the pid of the process to enable.public boolean enableForTesting(long windowHandle)
windowHandle for testing.windowHandle - the handle of a window in the process to enable..public void emitLowLevelEvent(LowLevelEvent event)
TestObject. These actions
are further broken down into more basic parts, so rather than something like TestObject.click()
which is comprised of a move, a mouse button down, and a mouse button up, you deal with each of those
sub actions individually.event - the LowLevelEvent to be played back.SubitemFactory.keyDown(String),
SubitemFactory.keyUp(String),
SubitemFactory.leftMouseButtonDown(),
SubitemFactory.leftMouseButtonUp(),
SubitemFactory.middleMouseButtonDown(),
SubitemFactory.middleMouseButtonUp(),
SubitemFactory.rightMouseButtonDown(),
SubitemFactory.rightMouseButtonUp(),
SubitemFactory.mouseMove(Point),
SubitemFactory.mouseWheel(int),
SubitemFactory.delay(int),
LowLevelEventpublic void emitLowLevelEvent(LowLevelEvent[] events)
TestObject. These actions
are further broken down into more basic parts, so rather than something like TestObject.click()
which is comprised of a move, a mouse button down, and a mouse button up, you deal with each of those
sub actions individually.events - the array of LowLevelEvents to be played back.SubitemFactory.keyDown(String),
SubitemFactory.keyUp(String),
SubitemFactory.leftMouseButtonDown(),
SubitemFactory.leftMouseButtonUp(),
SubitemFactory.middleMouseButtonDown(),
SubitemFactory.middleMouseButtonUp(),
SubitemFactory.rightMouseButtonDown(),
SubitemFactory.rightMouseButtonUp(),
SubitemFactory.mouseMove(Point),
SubitemFactory.mouseWheel(int),
SubitemFactory.delay(int),
LowLevelEventpublic java.awt.image.BufferedImage getScreenSnapshot()
public java.awt.image.BufferedImage getScreenSnapshot(java.awt.Rectangle rect)
rect - The portion of the screen to capturepublic java.awt.image.BufferedImage getScreenSnapshot(java.awt.Rectangle rect,
boolean clipToVisibleArea)
CoordinateOffScreenExceptionrect - The portion of the screen to captureclipToVisibleArea - If true, the method will consider only visible portion of the screen, otherwise throws CoordinateOffScreenException.public java.awt.image.BufferedImage getScreenSnapshot(java.awt.Rectangle rect,
java.lang.String fname)
rect - The portion of the screen to capture