Highlighted
Valued Contributor.
Valued Contributor.
234 views

Unable to fetch Background color of WPF Object

Jump to solution

Hi,

I am trying to fetch the background color of a WPFobject("GridRow") /WpfObject("Part_dataRow") using UFT 14.53. 

The AUT is a .NET Wpf application and there are no properties related to coloring when searched with Object Spy.

How to find the same?

Labels (5)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert
7 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi,

 

You may try something like below:

msgbox WpfWindow("MainWindow").WpfButton("Button").Object.Background.ToString()

explanation:

1. WpfButton("xxxxx").Object, the Object will expose the native object here, so you can access all the properties of the object. This Object is not only for .net or wpf, it can also apply to other TO like web.

2. Since in WPF, background is a brush type, it may be a SolidColorBrush or some other complicated Brush, no properties like background color. So we can only use the ToString to get the color if the background object is a SolidColorBrush. 

 

Thanks

Jerry

Take the Micro Focus UFT Family Survey for 2020! In just 10 minutes, your anonymous responses will help us create better experiences for you!

Take the Micro Focus UFT Family Survey!

 

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

@Jerry2 

I tried this, getting a runtime error "Object required- Object.Background" 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert
Please post your code. I think 'Object' should exist, the background may not exist. You may try to use intellisence to find out all possible properties for the Object.
And you also need to check the parent TO, which may contain the property you need.
0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Intellisence does pop up "object.Background" .    ToString doesn't pops up in the intellisense , i just typed that part.

code lines:-

WpfWindow("Window").WpfObject("ob1").Wpfobject("datapanel").Wpfobject("Gridrow").object.Background.ToString()

Note:

I have a wpfapplication with a Grid view that has certain "n" number of rows. Some rows are green in color, others are yellow. I need to fetch the row colors. There is no table of any kind in the application.

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I think this one is complicated.

WPF use Visual Element to store all the information like background color or style, looks like it's hard to get such an object.

I think this may need some code change or enhancement on our product, please open a ticket for this.

Thanks

Jerry

Take the Micro Focus UFT Family Survey for 2020! In just 10 minutes, your anonymous responses will help us create better experiences for you!

Take the Micro Focus UFT Family Survey!

Highlighted
Valued Contributor.
Valued Contributor.

I think this may need some code change or enhancement on our product, please open a ticket for this -  Can you please share the link for the same?

I checked with the developer. They provided the background property to one of the parent object Wpfobject("gridRowcontent") instead of Wpfobject("grid row"). However UFT doesn't spy any object by that name . I also checked a few parent objects in the hierarchy to see if any of them have the background color property associated, but no luck yet.

Hierarchy :

WpfWindow("Window").WpfObject("ob1").Wpfobject("datapanel").Wpfobject("Gridrow").object.Background.ToString()

so background color is ideally associated with any of these highlighted TO/PO, but couldn't find.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert
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.