WEB UI button search fails
-
Monday, September 17, 2012 2:28 PM
Hi,
I am attempting to automate testing of a web application using the CodedUI system. In doing so I get the definition of the buttons on the pages being tested. When I run the test, there are certain buttons that return a message that the control can not be found. I get a second definition of the button and sometimes it works, in a certain environment, and sometimes not.
I looking at the definitions of the problem control in the design file, the definitions are identical, but some of the definitions find the control and some don't. I can't seem to determine what the control discovery is looking for that could cause the problem. I have even added the alwaysSearch function in the code with appropriate search parametes and the button still can not be found.
What am I missing?
All Replies
-
Tuesday, September 18, 2012 6:16 AMModerator
Hello Pribina,
Thank you for posting in the MSDN forum.
I would like to know more information about your issue.
Which kind of controls will return a message that the control cannot be found? Can you give us detailed information about the error message?
You can check if the search property is valid. If you search for a control with an invalid property, some exceptions will occur.
For more information, you can see: FAQ: What happens if I search for a UI Test Control with an invalid property?
In addition, if you are using a pure hand-coding approach to authoring Coded UI Test and the control is the expandable control for example Tree and menu, you need to ensure that Expand While Searching configuration is set.
For detailed in formation, you can refer to this blog: Search Configuration–Expand While Searching
Also if there are some levels above your problem control, when you search the control, you had better to search from the top level instead of reduce some meddle levels.
The following blog about how does coded UI test find a control may help you.
How does “Coded UI test” finds a control ??
I hope it can help you.
Best regards,
Amanda Zhu [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, September 18, 2012 12:28 PM
Hi,
The control that is not found is a button on a web page of a web application. In checking the heirarchy of the control, the frame is found, but the document and control are not found.
Here is the error message for the control not found:
Test method XDM.Regression_Tests.Administration.Network.NetworkUsageAppWideTraffic_Test threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Document'
TagName: 'BODY'
RedirectingPage: 'True'
FrameDocument: 'True'
Failed to find any control that matched the search condition ControlType='Document' && RedirectingPage='True' && FrameDocument='True' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.I have checked the component's search criteria and there is no invalid criteria.
I will check the links in the last response to see if I can determine my issue.
Thanks
John Zabel
-
Wednesday, September 19, 2012 7:17 AMModerator
Hello John,
Based on your description, the control can’t be found because the search condition was not matched.
I would suggest you to record the same steps again and playback. You also can use Coded UI Test Builder to verify that the search properties of the control in UIMap are matching with actual properties of the control to successfully find the control.
In addition, you can try to search the control through search with other properties instead of those in your reply above to check if it helps.
I hope it is helpful to you.
Best regards,
Amanda Zhu [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, September 19, 2012 12:01 PM
Hi,
Upon further investigation it turns out the the control is not found because the page that it was linked to was not found. The page was not found because the page was listed as a redirection page, which is was not. Upon changing the redirection to false, the page was found and the control was found. Now, why the page was set for redirection as true is unknown. Since none of the controls or pages were hand coded, they were all recorded, there may be a problem with the recorder or there is some other unknown issue.
John
John Zabel
- Marked As Answer by Amanda ZhuMicrosoft Contingent Staff, Moderator Thursday, September 20, 2012 12:26 AM
-
Thursday, September 20, 2012 12:26 AMModerator
Hello John,
Glad to see this issue has been resolved and thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.
Best regards,
Amanda Zhu [MSFT]
MSDN Community Support | Feedback to us

