Reputation: 1068
I'm tearing my hair out with this one. I have a simple coded UI test built in Visual Studio 2012 against IE 11. All I'm attempting to do is log in, check that the UI displays that the user is logged in, then log out. The coded UI test works up until logged out. When I attempt to log out, I get:
TechnologyName: 'Web' ControlType: 'Custom' TagName: 'form' Id: 'logoutForm'
Failed to find any control that matched the search condition Id='logoutForm' && ControlType='Custom' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
The filters/search conditions appear correct. I'm not sure why it's not working. The html for the logout button is as follows
<form action="/Account/LogOff" class="navbar-form " id="logoutForm" method="post"> <input name="__RequestVerificationToken" type="hidden" value=""><a class="btn btn-primary btn-sm" href="javascript:document.getElementById('logoutForm').submit()"><i class="icon-remove"></i> Log off</a>
</form>
I'm just not sure what the problem is and why it's failing. I've tried removing the blank fields or adding an explicit ID, all to no avail. I also tried playing with search configurations and it didn't seem to help. Within VS, I right click the hyperlink and click locate control, and it properly highlights the control. I'm at a loss. I appreciate any guidance.
UPDATE: Here's the generated code for the button
[GeneratedCode("Coded UITest Builder", "11.0.60315.1")]
public class UILogoutFormCustom : HtmlCustom
{
public UILogoutFormCustom(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties["TagName"] = "form";
this.SearchProperties["Id"] = "logoutForm";
this.FilterProperties["Class"] = "navbar-form ";
this.SearchConfigurations.Add(SearchConfiguration.DisambiguateChild);
this.WindowTitles.Add("someTitle");
#endregion
}
#region Properties
public HtmlHyperlink UILogoffHyperlink
{
get
{
if ((this.mUILogoffHyperlink == null))
{
this.mUILogoffHyperlink = new HtmlHyperlink(this);
#region Search Criteria
this.mUILogoffHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Id] = "logOffButton";
this.mUILogoffHyperlink.SearchProperties.Add(new PropertyExpression(HtmlHyperlink.PropertyNames.InnerText, "Log off", PropertyExpressionOperator.Contains));
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = "document.getElementById(\'logoutForm\').submit()";
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Title] = null;
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Href] = "javascript:document.getElementById(\'logoutForm\').submit()";
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Class] = "btn btn-primary btn-sm";
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.ControlDefinition] = "class=\"btn btn-primary btn-sm\" href=\"jav";
this.mUILogoffHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.TagInstance] = "1";
this.mUILogoffHyperlink.WindowTitles.Add("some title");
#endregion
}
return this.mUILogoffHyperlink;
}
}
Note the search configuration is something I was trying, but usually it's not set.
#region Variable Declarations
HtmlHyperlink uILogoffHyperlink = this.UIPrefereWindow.UIPrefereDocument.UILogoutFormCustom.UILogoffHyperlink;
#endregion
// Click 'Log off' link
Mouse.Click(uILogoffHyperlink, new Point(26, 23));
Upvotes: 1
Views: 6831
Reputation: 6259
You have my every sympathy and I feel your pain. I don't know if I'm facing the same issue as you but it seems IE 11 and Coded UI appear to * hate * each other. Certainly that's been my experience when it comes to running IE as different user. I've reported this to Microsoft but had no joy - see the links on this question:
Cannot run Coded UI tests as different user on Windows 8.1
My advice (and you won't like it) is to do what I'm doing and maintain a VM with older versions of IE / Visual Studio etc on it and use that when working on Coded UI tests. Horrendous but it appears to be the only option.
Upvotes: 0
Reputation: 441
With what limited info you've provided I have a couple of suggestions to get you started:
Upvotes: 1
Reputation: 422
i have 2 suggestions for you, hope they work:
What is your keyboard language? If it's not English (i had the similar problem with my keyboard as well) change your settings to that and record again.
Have you tried visual studio 2013? I'm using Ultimate, and working good so far.
Upvotes: 0