2

I am testing web based application and want to select radio button, but am unable to select it using coded UI automation. I have tried to find it using ID, Name, Value but all throwing the same error. What could be the reason?

Result Message:

Test method SampleTest.LoginPage.LoginTest.Login_Sample 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:
'CheckBox' TagName:  'INPUT' Value:  '104677'  Failed to find any
control that matched the search condition Value='104677' &&
ControlType='CheckBox' --->
System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has
been returned from a call to a COM component.
1
  • Can you post your code so we can try and help?
    – Tango199
    Mar 3, 2016 at 19:36

5 Answers 5

1

Issue here seems to be that you are using you are using the wrong control type. If you want to check/select Radio button then you need to use the RadioButton control type in CodedUI not the Checkbox type, then locate that Radio button with the ID or name or anyother locator and then select the value example:

HtmlRadioButton html_radioBtn = new HtmlRadioButton(brw); //brw is the Browser window which contains the Radio Button field or you can use a UITestControl to locate a area to be looked for RadioButton
html_radioBtn.SearchProperties.Add(HtmlRadioButton.PropertyNames.Id, "locatorID"); //locatorID = ID of the Radio Button control
html_radioBtn.SearchProperties.Add(HtmlRadioButton.PropertyNames.Value, "valueToBeSelected"); //valueToBeSelected = Value of the Radio Button to be checked e.g. 104677
html_radioBtn.Selected = true;

Actually, CodedUI has different type for different controls, and if one doesn't use the correct the one, it throws error. This should work for your issue, if not then I will need the Html and the sample code which you are using.

1

This is a basic control not found error, I would start working up the Automation tree with the control's parents to see that you can find each one using the drawhighlight function below, and then work your way down to this control using this function to troubleshoot and find at which level the search is failing.

control.Drawhighlight(); 

You can also inspect the control using Microsoft's "VisualUIAVerify" tool to see that you have the correct search properties configured such as the AutomationId and Name of the control.

0

The object must match every identifier that you have added so if any identifiers are wrong, it will fail. Get rid of all identifiers that you do not specify yourself and add them back one by one.

0

If your Radio button id or innertext or value changing dynamically , coded ui test not support that dynamic control value change. Coded ui test not have feasibility of control id or text correlation

0

Work around : Open Your browser and continue your scenario manually until that control click on it and inspect or Click f12 , it gives value of that control go to your coded ui script designer.cs and find control properties and replace your value. and run your script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.