This project is read-only.

Cannot find HTMLComboBox on playback

May 15, 2012 at 8:43 PM
Edited May 15, 2012 at 10:09 PM

In my object repository I have defined two combo boxes and a textbox like so...

	public class SearchPage : Common
                public new string sWindowTitle = "BugTracker.NET - search";
		public CUITe_HtmlComboBox cboAssignedTo = new CUITe_HtmlComboBox("Id=assigned_to");
                public CUITe_HtmlComboBox cboProject = new CUITe_HtmlComboBox("Id=project");
		public CUITe_HtmlEdit txtCommentsContains = new CUITe_HtmlEdit("Id=like2");

The HTML page these objects are based on is here...

<table border=0 cellpadding=3 cellspacing=0>
		<td nowrap><span id="project_label" class="lbl">project:</span><br>
			<select size="6" name="project" multiple="multiple" id="project" onchange="set_project_changed()">
	<option value="0">[no project]</option>
	<option value="1">project 1</option>
	<option value="2">project 2</option>

In a TestMethod, I try to use these items like so...

            BTSearchPage.txtCommentsContains.SetText("This is a test");

However, only the first line works. If I use either of the next two lines individually, I get the following error...

Test method BugTracker.CUITe.Tests.SearchTest.SearchUsingReportedByFieldOnly 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:  'ComboBox'
TagName:  'SELECT'
Id:  'project'
 Failed to find any control that matched the search condition Id='project' && ControlType='ComboBox' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

I'm using the latest CUITE version. It's a simple combo box and I think I am setting up the test correctly. Is there a bug?

May 16, 2012 at 2:15 AM


If you view the source on the generated web page in your web browser at the time of the error, is there more than one select element with id="project" ?

I am also wondering if the exception occurs before the web page has completely finished loading?

Thank you.

May 16, 2012 at 5:32 PM
Edited May 16, 2012 at 5:33 PM

I searched the whole document for "Id='project'" and only one item came up.

I did a delay before the lines using the combobox and it failed with the same error. The first line "

BTSearchPage.txtCommentsContains.SetText("This is a test");"

is working so I think the page has loaded already.

May 17, 2012 at 8:04 AM


Since your <select> element has a size attribute, it is actually rendered as a list.

I was able to reproduce the issue you encountered and this is how I resolved it:


public CUITe_HtmlList cboProject = new CUITe_HtmlList("Id=project");

HtmlListItem listItem = new HtmlListItem(BTSearchPage); listItem.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch); listItem.SearchProperties.Add(HtmlListItem.PropertyNames.InnerText, "project 1"PropertyExpressionOperator.Contains); Mouse.Click(listItem);

Thank you.


May 17, 2012 at 8:08 AM

I created a work item to implement an HtmlListItem wrapper here:

May 17, 2012 at 6:09 PM

Awesome! Thank you sir. The workaround worked for me as well  =)