2013-10-25 88 views
1

我正在用這個彈出我的頭髮。我在Visual Studio 2012中針對IE 11構建了一個簡單的編碼UI測試。我試圖執行的所有操作都是登錄,檢查UI是否顯示用戶已登錄,然後註銷。編碼的UI測試工作直到註銷。當我嘗試登錄時,我得到:Visual Studio編碼的UI測試播放無法找到控件

TechnologyName:「網頁」 ControlType:「自定義」標籤名:「形式」編號: 「logoutForm」

無法找到符合搜索任何控制條件 Id ='logoutForm'& & ControlType ='Custom'---> System.Runtime.InteropServices.COMException:錯誤HRESULT E_FAIL有 已從調用COM組件返回。

過濾器/搜索條件顯示正確。我不確定它爲什麼不起作用。對於註銷按鈕的HTML如下:

<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> &nbsp;Log off</a> 
    </form> 

enter image description here 我只是不知道是什麼問題,爲什麼它的失敗。我嘗試刪除空白字段或添加一個明確的ID,都無濟於事。我也嘗試使用搜索配置,似乎沒有幫助。在VS中,我右鍵單擊超鏈接並單擊定位控件,並正確突出顯示控件。我很茫然。我很欣賞任何指導。

UPDATE: 下面是按鈕

[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; 
     } 
    } 

注意生成的代碼搜索配置是我是想,但通常沒有設置。

#region Variable Declarations 
     HtmlHyperlink uILogoffHyperlink = this.UIPrefereWindow.UIPrefereDocument.UILogoutFormCustom.UILogoffHyperlink; 
     #endregion 

     // Click 'Log off' link 
     Mouse.Click(uILogoffHyperlink, new Point(26, 23)); 
+0

嘗試最新的Update 4 RC:http://blogs.msdn.com/b/visualstudioalm/archive/2013/09/17/coded-ui-mtm-issues-on-internet-explorer-with-kb2870699。 aspx – magicandre1981

+0

感謝您的建議。試過了。同樣的東西 –

+0

您可以發佈試圖訪問該控件的代碼嗎?另外,您是否可以確認控件在運行的開始和結束時確實是相同的控件。有時看起來相同,但一些細節變化可能會打破測試。使用測試生成器中的十字線來與捕獲的控件進行比較。 – yonitdm

回答

0

我對你有2組的建議,希望他們的工作:

  1. 什麼是你的鍵盤語言?如果不是英語(我的鍵盤也有類似問題),請將您的設置更改爲該設置並再次錄製。

  2. 您是否試過Visual Studio 2013?我正在使用Ultimate,迄今爲止工作良好。

+0

英文。我即將嘗試VS2013,希望能夠工作 –

+0

應該提到我也會在win7 ie10機器上嘗試vs2012 ult,當我有機會的時候。 –

+0

Justi安裝了VS2013,我遇到了同樣的問題 –

1

用什麼限制信息您提供我有一些建議,讓你開始:

  1. 重新啓動Visual Studio,討厭,但只要我看到這個錯誤在那裏它不應該,重啓是一個快速修復。
  2. 如果問題仍然存在:您是否可以將控制權限降低爲TechnologyName:'Web'Id:'logoutForm'?如果一個對象有一個ID,通常沒有必要擁有其他信息。
  3. 仍然無法正常工作?我一定會需要更多的信息,以知道什麼是錯的:)
+0

嘗試重新啓動VS.我嘗試刪除一切,但id。還是行不通。我可以提供哪些更多信息?謝謝你的建議 –

+0

我對原始問題發表了一些意見:) – yonitdm

0

你有我的每一個同情,我感到你的痛苦。我不知道我是否面臨與你同樣的問題,但似乎IE 11和編碼的用戶界面似乎* 討厭 *彼此。當然,這是我作爲不同用戶運行IE的經驗。我報這個微軟,但沒有喜悅 - 看到這個問題的鏈接:

Cannot run Coded UI tests as different user on Windows 8.1

我的建議(你不會喜歡它)是做我在做什麼,並保持虛擬機具有較舊版本的IE/Visual Studio等,並在編寫UI測試時使用它。駭人聽聞,但它似乎是唯一的選擇。

相關問題