Fatlad
Fatlad

Reputation: 334

failedtoperformactiononhiddencontrolexception despite the textbox being clearly visible

I have a wpf application which has a text box in which I can write a text value to just fine the first time around. If I exit the window the text box is in and then reopen that same window the box can no longer be found by the testing, despite being enabled, and clearly visible on my screen.

I looked at the values of the box, the x,y = -1,-1 and height,width are also -1,-1 which is confusing seeing as the box is completely visible.

I know what the text in the box will be, is it possible to search for a text box with that as a workaround?

I'll keep researching this but any feedback is appreciated :)

EDIT: Upon further study there is a second field on top of the original field providing an initial explanation as to what the box is for ("Enter field value").

Maybe this is a wpf error?

Upvotes: 0

Views: 928

Answers (2)

Fatlad
Fatlad

Reputation: 334

I found that the box wasn't being updated properly on the UIMap. This can be solved by setting the application windows SearchConfinguration (only in the specific test) to always search like so:

    UIMap.ApplicationWindowName.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

Apparently this can cause a performance hit but I haven't noticed!

Upvotes: 3

AdrianHHH
AdrianHHH

Reputation: 14038

I would look at the SearchProperties and FilterProperties of the text boxes, I suspect that two have been found and the wrong one is chosen. Or, it may be that the second window has some different values for the properties used to identify the windows.

One idea: Run the program again manually, move the first window with the text box to one corner of the screen, then close that window. Cause the window to be reopened and move it to the opposite corner of the screen; leave the window on display. Open the UI Map of the Coded UI test and use the Locate command to find the box - it should draw a blue line around the text box.

Another idea is to call FindMatchingControls (as shown in Coded UI conditional check on a method is not working) then use the properties (such as some of x, y, height, width) to select the wanted control.

I doubt if it is a WPF error, but it may be an error in the WPF application where it is not clearing up properly when the first window closes.

Upvotes: 2

Related Questions