1

I am using codedUI to automate my test cases. And our developers use Kendo UI control by Telerik. I don't have any problem with the recording and playback with controls which have unique names. But we have few controls which are rendered dynamically on the same document and only has name as unique identifier and the html is automatically created and our developers don't have control to modify the name or add id to that html. So the name has GUID automatically added, and this GUID changes most of the times when the test case runs. I tried using controls instead equals operator on the name field but as the GUID is in middle of the name, it is very difficult to use it. For example these are the names of the two controls, "Courses[138a47d6-8313-4df4-b39f-caeffd0aecf2].ExternalCoatingId_input" and "Floors[4fabd16d-4051-4547-bb6d-0847bddc05fbb6d-0847bddc05fe].ExternalCoatingId_input". So now in the search properties if I have to use Name I use contains on Name (i.e. Name. Contains(Courses) or Name. Contains(ExternalCoatingId_input)) which don't serve as unique search criteria. What I actually need is Name or ID like "Courses_ExternalCoatingId_input_GUID". So my developers understood my problem and added IDs in the format I requested, but as they don't have control over automatically generated html, they created a hidden control linked to that actual control with name above and added ID to it. Below is the sample html code for a control of that kind.

" span class="k-widget k-combobox k-header" style="width: 220px;" span class="k-dropdown-wrap k-state-default" unselectable="on" tabindex="-1"> input class="k-input" type="text" autocomplete="off" name="Courses[138a47d6-8313-4df4-b39f-caeffd0aecf2].ExternalCoatingId_input" style="width: 100%;" role="combobox" aria-expanded="false" placeholder="Select External Coating ..." tabindex="0" aria-disabled="false" aria-readonly="false" aria-autocomplete="both" aria-owns="tank-component-external-coating-Course-a490312e-c9f5-494a-8d3f-3ccdc33f7660_listbox" aria-activedescendant="tank-component-external-coating-Course-a490312e-c9f5-494a-8d3f-3ccdc33f7660_option_selected" aria-busy="false">

span class="k-select" unselectable="on" tabindex="-1"> span

input id="tank-component-external-coating-Course-a490312e-c9f5-494a-8d3f-3ccdc33f7660" type="text" style="width: 220px; display: none;" name="Courses[138a47d6-8313-4df4-b39f-caeffd0aecf2].ExternalCoatingId" data-val-number="The field ExternalCoatingId must be a number." data-val="true" data-role="combobox" aria-disabled="false" aria-readonly="false"

span "

But Now when I try to add this ID in UImap.uitest for that control and try to playback the test it is giving error saying "{"Cannot perform 'Click' on the hidden control. Additional Details: \r\nTechnologyName: 'Web'\r\nControlType: 'Edit'\r\nTagName: 'INPUT'\r\nId: 'tank-component-external-coating-Roof-7341237e-a359-4fb9-b9a3-29a282c44480'\r\nName: 'Roofs[4400736d-2a50-40ae-87f2-41acdf200e1f].ExternalCoatingId'\r\n"}" I am using Visual Studio 2012 Premium and Windows 8 OS and IE 10

I apologize for the very elaborate explanation of the problem, but I couldn't find any help in any of the forums which is this specific. I found few forums threads discussing about "cannot click on hidden control" but is totally unrelated to my issue. I appreciate any suggestions on how we can use that hidden control ID and execute my tests case successfully.

Thanks, Raji

2
  • Can you lay out what the HTML around the controls looks like? For example, do you have a div wrapping both the hidden and shown controls? Commented Oct 31, 2013 at 13:17
  • Yes there is a Div wrapping both the controls.. And here is the sample Commented Nov 1, 2013 at 22:14

2 Answers 2

1

I would consider not using the hidden controls but focus on the real controls. The way I would try is to specify the search properties with a Contains(ExternalCoatingId_input) and add a filter property of Contains(Courses). That may be sufficient. If it is not then try using FindMatchingControls() which will return a UIControlCollection with all the controls found. You can then search the collection to find the control you want, the question does not say what these other search criteria might be.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the suggestion but the problem is we can add the same property called "Name" in Filter and search properties. It will not allow you to do that.
0

Two solutions come to mind.

One, you could execute a click on the location of the hidden control - That's done by getting the bounding rectangle of the control and clicking on it -

Mouse.Click(new System.Drawing.Point(hiddenControl.BoundingRectangle.X + 5, hiddenControl.BoundingRectangle.Y + 5)); 

That's fine for clicking on controls, but if it's a drop down list or something else and you want to do more than just click, you need the control itself. In that case, then you need to find a common parent of both the hidden control and the real control that isn't a parent of another example of the real control.

For example, let's say you've got your hidden control(We'll call it hiddenControl) and your drop down list(We'll call it noIDList). Let's further say that both of them are contained within the same HtmlSpan. First, set up hiddenControl in your UI map like you would any control, using its ID. Then, when you declare noIDList in your UIMap, you can narrow it's parent to be the same parent that hiddenControl has using the GetParent() method. Here's how:

public HtmlComboBox noIDList { get { //This returns the first combo box that is a child of hidden control's parent //So, the first combo box that is a sibling of hidden control return new HtmlComboBox(hiddenControl.GetParent()); } } 

Obviously, this requires that both the hidden control and the combo box share a parent and that parent does not also contain all of the other hidden controls and combo boxes. Cheers and good luck!

2 Comments

Thanks for your response, Yes I need to use it on drop downs, so I think your second solution might work. But I have never written any code like the one you listed above, so it will take me more time to research. I will keep posted if this solution worked.
I tried this but when I am setting up the hidden element it is returning null because it is not able to find that hidden element on the current document. Can you please let me know if I am doing something wrong. Thanks, Raji

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.