Jesterboy Contributor.
Contributor.
502 views

UFT 14.0 doesn't read Java Objects correctly to get text

Hello Everyone,

I was wondering if someone could help me? I am testing a Java 1.7 POS application. I have a Java Object that I have added to the repository that is essential the output of a running total. So it's always just a dollar amount like $425.00. When I add this object to the repository and then try to get the text from the object UFT is never able to get the text. I looked online and many people recommended adding it as a Insight Object. This approach kind of works, however; it has some issues. Example if the total changes enough the Insight Object no longer can read the text and it throws a error. If the Insight Object was done on $425.00 and the new amount is $25.00 the object has changed too much and causes a error. I am at a bit of a loss here because I don't want to have to create a Insight Object for every script. This creates a bloated repository and a lot of manual changes. Is there there any other way to get the text from a java object without going through all of this?

Any help is greatly appreciated.

Jester

0 Likes
4 Replies
Jesterboy Contributor.
Contributor.

Re: UFT 14.0 doesn't read Java Objects correctly to get text

Is this the best solution to be testing stand alone java applications? It seems like most places only want to look at this tool as a way to test Java Web Applications and the object spy it very limited as to what it can detect in these objects.

0 Likes
Super Contributor.. mu21 Super Contributor..
Super Contributor..

Re: UFT 14.0 doesn't read Java Objects correctly to get text

Hello,

What kind of Java Objects is it? If it is a custom object, you will probably have to write your own functions to retrieve the value you need. 

You need to identify which property holds the value you're trying to test (use Object Spy). If none of the Identification property has that value, then you will have to go down to the object level and use native properties to retrieve this value but you need to know something about the object you're working with.

 I use UFT to automate testing of a Java application. For some type of Java Objects, I'm lucky enough that the value I want to test is found within an identification property so then it's easy. For others, I had to write my own function to do handle the object because UFT cannot do it natively. 

 

 

0 Likes
Jesterboy Contributor.
Contributor.

Re: UFT 14.0 doesn't read Java Objects correctly to get text

Hello, Thanks for your response. So a little background information, the company I work for leases the application from a 3rd party vendor so we don't own any source code nor access to any api's that I can connect to. So most of my automation testing has to be done more on a surface level. We have reached out to the vender to help identify these objects however it's getting expensive because it's all treated as enhancement work. When I object spy the Java object which I assume is a basic text or maybe a label of some sort I get the following:

"Class Name:=JavaObject",
"abs_x:=500",
"abs_y:=360",
"attached text:=",
"background:=eeeeee",
"class description:=object",
"class_path:=uk\.co\.datafit\.system\.engine\.TransparentIndicator\$LightCanvas;java\.awt\.Component;java\.lang\.Object;",
"developer name:=TDbalance",
"displayed:=1",
"enabled:=1",
"focused:=0",
"foreground:=white",
"height:=32",
"index:=",
"label:=",
"labeled_containers_path:=",
"logical_location:=",
"path:=TransparentIndicator\$LightCanvas;ViewerPanel\$ViewerContainerHolder;ViewerFrame;ViewerFrameset;ViewerFrame;ViewerFrameset;ViewerFrame;ViewerFrameset;ViewerFrame;ViewerFrameset;ViewerFrame;JPanel;JLayeredPane;JRootPane;ViewerApplet;JPanel;JLayeredPane;JRootPane;ViewerMain;",
"tagname:=TransparentIndicator\$LightCanvas",
"text:=",
"to_class:=JavaObject",
"to_description:=JavaObject",
"toolkit class:=uk\.co\.datafit\.system\.engine\.TransparentIndicator\$LightCanvas",
"width:=190",
"x:=500",
"y:=360"

If I need to write a function out to parse the text out would you have any examples anywhere as to how this is done? 

Again I appreciate any help I can get in this!

Thanks,

Jester

0 Likes
Super Contributor.. mu21 Super Contributor..
Super Contributor..

Re: UFT 14.0 doesn't read Java Objects correctly to get text

Hello,

That's the problem when you don't have access to the code because UFT will work out of the box only with standard Java Objects but it won't correctly recognize user-defined objects.

UFT can access native properties and operations. In Object Spy, you need to select the "Native" radio button (just above the list of properties/operations) to see the list of available properties and operations. In your code, you then need to go down to the object level :

Set obj = JavaWindow("...").JavaObject("...").Object

Then, the functions that will allow you to retrieve the value you're looking for will depend on the object and how it was coded. I don't know if there is a quick way of finding the one you need (the list of available properties and operations may be rather long), I'm not an expert and definitely not a Java expert. In my case, the application is developed internally so I can ask the developer exactly what function to use or I can even ask them to code a function that I can then use.

In your code, you would then use the function as follows:

obj.<function_name>

For example:

obj.getCurrentText()

obj.getText()

obj.combo.getText()

obj.getSelectedText.toString()

But the code required may be much more complex than that. 

 

 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.