UFT/QTP - Can not find Objects parent - testing

I can not access an object in my testcase.
The object is a Tab, attached to a (Sub)Window in my application.
Befor and after the Testcase the Tab and the window the tab is attached to is found by the object spy fine, but while the testcase runs the Error below comes up .
Cannot find the "[ActiveX]" object's parent "[Window]" (class Window). Verify that parent properties match an object currently displayed in your application.
I access the object so :
VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab")
I am new to UFT, so I searched a while and found some solutions but they seem not to work for me, because they always related to browser testing, not application.

Warning: Long explanation follows, you can skip to the last paragraph for a suggested quick win.
When UFT identifies objects it does so from the top down, your object hierarchy is:
VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab")
And UFT said that:
Cannot find the "[ActiveX]" object's parent "[Window]" (class Window).
This means that id did find VbWindow("ApplicationWindow") but could not find the Window("SubWindow"). Try highlighting the VbWindow to make sure that UFT is identifying the object you expect. Then use the object spy to inspect the window you think UFT should find. Then compare the properties in the object repository to those of the window you see and find how these descriptions differ.
As a shortcut you can try using Maintenance Run Mode which should do these steps for you and suggest a way to fix the test.

Just a thought to identify the root cause of the problem.
1.Try with the top level container(skipping the next level container) and check your existence of parent.
VbWindow("ApplicationWindow").ActiveX("Tab")
2.Check the properties before and after. I meant side by side validation. There could be the chance of property mismatch.
3.Use Refresh Object method.
Window("Calculator").RefreshObject
4.Query your parent from the Tab object
Set objParent = VbWindow("ApplicationWindow").ActiveX("Tab").GetTOProperty("parent")
Msgbox objParent.GetROProperty("text")
Set objParent = VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab").GetTOProperty("parent")
Msgbox objParent.GetROProperty("text")

Related

How do I start Etoys from Squeak?

In the Squeak System Browser, I see that there are many class categories related to Etoys:
But how do I access Etoys from Squeak? How do I get something like the screenshot shown below?
(Source of Etoys screenshot: https://commons.wikimedia.org/wiki/File:Squeak_screenshot.png)
There are also Squeak versions set up specifically for Etoys, e.g.:
https://squeak.js.org/etoys/#fullscreen
I think there is easier way than Leandro is proposing.
Just run the Workspace from the menu where you type:
Project enterNewWithInitialBalloons
Select it with mouse and run it - Do it (alt+d). Application should start. I'm unfamiliar with the application. To me it looks similar to the picture you show.
Edit: how did I find it?
I searched through the source code. I have to agree that this is not straight forward.
First I tried to find anything that has to do with Etoys project/class. I tried to find anything that would indicate that you can start it.
This way I found Etoys-Experimental package with class EToysLauncher. The word launcher to me sounded like it could be launched. I looked at the class of the EToysLauncher where I found instance creating protocol where you can find these methods (remember we are still at the experimental package!):
#buildGallery
#buildPanel
#openGallery
#openPanel
If you go through these e.g. EToysLauncher openPanel you will get a message doesNotUnderstand: #latestProjectVersionsFromFileEntries. I then started to investigate the Walkback. I tried to check what is the issue here. I got this message because of the last line ^ Project latestProjectVersionsFromFileEntries: entries.
I went to the Project>>latestProjectVersionsFromFileEntries: to check what it is actually doing. In meantime I have inspected the values from the entries variable in the debugger. In the entries I could find an OrderedCollection but nothing what would satisfy #('*.pr' '*.pr.gz' '*.project') from the method. So I thought to myself, that perphaps the Project itself could satisfy it.
I went to the Project class and protocol Etoys-Squeakland-instance creation where I found two methods #enterNew and #enterNewWithInitialBalloons.
The #enterNew gives doesNotUnderstand: #newMorphicOn: so I skipped that one and tried the #enterNewWithInitialBalloons, which worked and since it is in the protocol Etoys-Squeakland-instance creation I came to the conclusion it has create Etoys-Squeakland new instance.
Edit: Show shared flaps?
Yes, you can activate the flaps also via Show shared flaps.
There is, however, quite a difference between running the Project enterNewWithInitialBalloons and Showing the shared flaps via Preferences.
If you start the Etoys via the Project enterNewWithInitialBalloons you will start completely new project (your currently opened windows will be hidden). To see your previous windows you need to either Porojects/Enter Project and switch to the HomeProject or you have to close the newly opened project via Projects/Close This Project.
The source that shows it is:
enterNewWithInitialBalloons
| newP |
newP := MorphicProject new.
newP world addMorph: (DoCommandOnceMorph new extent: 1#1; actionBlock: [SugarNavigatorBar putUpInitialBalloonHelp]; yourself).
newP enter.
This creates new MorphicProject and to this project it adds new Morph.
On the other hand, if you start it with Preferences/Show shared flaps the flaps will be just added to your current environment without creating a new project.
The source that shows it is: Preferences class >>sharedFlapsSettingChanged
sharedFlapsSettingChanged
"The current value of the showSharedFlaps flag has changed; now react"
self showSharedFlaps "viz. the new setting"
ifFalse:
[Flaps globalFlapTabsIfAny do:
[:aFlapTab | Flaps removeFlapTab: aFlapTab keepInList: true]]
ifTrue:
[Smalltalk isMorphic ifTrue:
[self currentWorld addGlobalFlaps]]
The self currentWorld addGlobalFlaps adds the flaps to the currentWorld. The PasteUpMorph>>addGlobalFlaps creates new PasteUpMorph and adds it.
You can also notice the difference also in the menu bar title Untitled vs. HomeProject.

How to use a custom icon in a dolphin smalltalk treeview?

In a Dolphin smalltalk treeview I'd like to use a custom icon, depending on the state of the item displayed, (differente state, different icon)
How can I do that ?
I cannot really understand how to use a "my" icon.
I've create a class "connection", with an instance variable "connected"
and two class methods "connectedIcon and unconnectedIcon that returns icon images.
Then an instance function "icon" that returns one or the other image based on the connection state.
I can add instances of this class to a tree view and see the name of the connections.
But how to show my Icons ?
I tried to sustitute the getImageBlock of my presenter view with the following expression [:obj | obj icon] but it doesn't work.
(nothing seems to happen).
this is made in my presenter initialize :
initialize
super initialize.
treePresenter view getImageBlock: [:obj | obj icon]
what's wrong with it ?
best regards
Maurizio
When you are editing a TreeView, one of the properties is getImageBlock. By default it is not really a block but another object that understands the message #'value:' (the class IconicListAbstract). You can replace this property with a code block (or other object that understands #'value:') and answer the image you want displayed.
In Microsoft Windows, icons are typically stored in a DLL. You should be able to use an icon explorer or editing tool to see the icons in a dll. For example, get IconExplorer from http://www.mitec.cz/iconex.html and try opening DolphinDR7.dll. Do the icons and numbers match what you see when you return a number in your application?
To determine (or override) the resource library used, see SessionManager>>#'defaultResLibPath'.
Typically, the getImageBlock is set using the property editor in the GUI editor, but setting it through code can work as well.
Wonderful Dolphin Smalltalk!
I had two problems
1) how and where to modify the getImageBlock method of my Treepresenter.
2) where to put the icons ad how to get the imageindex of each icon.
This is the solution :
1) it's not needed.
The treeview sends an #iconImageIndex" message to my model
this is handled by the default method (in the Object class) that send to my object the message #icon
and to the result of this message (an icon) the message #iconIndex.
This message is understood from the icon that answers with its own iconIndex.
So the only method I need to impement is #icon in my class Connection
that I implemented as follows:
icon
opened ifTrue: [^Connection connectedIcon] ifFalse: [^Connection unconnectedIcon]
In the class itself the two icons are imported in the image by evaluating the createIconMethod,
as explained in the blog article 'Beauty with less Beast'.
So my problems are solved.
Thanks to all.
Maurizio.

IBM RFT does not find .net object from framework

I have to check a frame window with RFT which is written with a .net framework. My problem is, after adding the frame as Testobject via drag and drop to the script it works fine. But after restarting RFT, it isnt able to recognize that frame any more, neither with find method or the highlight function for objects.
I read that there is a way to add objects to the proxys. But this frame is declared at proxy .Net.FormProxy and this proxy is existing in the file rational_ft.rftcust as
<Obj L=".Proxy">
<ClassName>Rational.Test.Ft.Domain.Net.FormProxy</ClassName>
<Replaces/>
<UsedBy>[System.Windows.Forms]System.Windows.Forms.Form</UsedBy>
</Obj>
I dont get what is the problem. Especially, why is it working some times but not always.
Thx for help..
The problem you have mentioned may happen for the following reasons.
The object recognition is indeed changing . And it is not necessarily the object that you are having problem with has object recognition issue , but an object in the parent heirarchy of this object (unless this object is the top level object).
The second reason could be the application is not getting enabled during playback time and you can try getRootTestObject().enableForTesting(/) API to force enable the application.
On a recorded Form object in the Object Map try to use the "update recognition properties" to see if there is change in recognition properties in actual vs recorded object.
You can also just test a different simple Form Application to see if the issue is related to your application or if it is general issue in your environment( I suspect it to be related to the application).

Identifying objects in IBM RFT

While executing my script in RFT, my script got failed due to the slight position change of a button. (This button's position slightly changes according to the option selected for previous combo box due to the label appearing near the button)
As there are 2 positions for this button in window, one of my script fails while other passes.
Please suggest how to identify this same object in 2 different places in RFT?
If you're alright with not using pre-mapped values and instead work with objects directly in code (which I've personally found to be extremely useful... it's allowed me to do great and wondrous things with RFT :), the following ought to work fine:
private void clickObject(String uniqueIdentifier) {
// Find object
RootTestObject root = RootTestObject.getRootTestObject();
TestObject[] matchingObjs = root.find(atProperty(".id", uniqueIdentifier));
if (matchingObjs.length > 0) {
// Click the object
((GuiTestObject) matchingObjs[0]).click();
}
// Clean-up
unregister(matchingObjs);
}
Feel free to replace ".id" with whatever property is best suited for the situation... since I work primarily with a web application, the ".id" property has worked splendidly for me.
Because the method finds the object anew each time, it'll grab the object's position wherever it's at at the time the method's called. The clean-up will also prevent any weird, horrible, and otherwise unfortunate UnregisteredObjectExceptions from cropping up.
Without looking at your pages I cannot be sure, but I think the buttons are actually two different buttons. Maybe they are generated by javascript, or they are just un-hidden after the option you select in the combobox.
If they are two different buttons (record them both and look at the recognition properties) you can either replace some properties with a regular expression or check wich button is visible/exists and then click it:
if (btn_button1.exists()) {
btn_button1.click();
} else if (btn_button2.exists()) {
btn_button1.click();
}
Here's a more complete tutorial on Object Recognition.
You can increase the tolerance of Rational Performance Tester AssureScript in the properties tab or you could set the description but hide the value. You can also make a custom code that updates the object map to prepare for this change in a java IF structure

How to display BlackOil in Petrel Function Window programatically

How do you display the Oil/Water/Gas components of a BlackOil domain object programatically on the FunctionWindow? I tried calling FunctionWindow.ShowObject on BlackOil.OilPhase but received an error that it could not be found on the input tree.
I need to say sorry here, but this is the bad case when you can get an programmatically access to the object via FluidFunctionCollection (you can create/update it), but you cannot get access to the same object via InputTree interface (you will receive an UnknownEntity via GetType method when try to navigate from Petrel UI to this object type and send it to your plug-in (doesn't exposed for Ocean from this site yet)), and by this reason you cannot display this object programmatically. I submitted an internal ticket for your case.