2013-10-18 144 views
0

我試圖在VS 8中使用IE 8在IE 8兼容模式下創建UI測試,但是當嘗試記錄操作記錄很多步驟失敗時。然後,當我在缺少的步驟中手動編碼並嘗試使用用戶名和密碼填寫登錄表單時,我得到一個異常,表示我未能對隱藏控件執行操作。無法對隱藏的控制異常執行操作

的UI測試代碼:

public void Recordedmethod() 
{ 
     BrowserWindow uILogInWindowsInternetWindow = this.UILogInWindowsInternetWindow; 
     HtmlHyperlink uILogInHyperlink = this.UILogInWindowsInternetWindow.UIHomePageDocument.UILogInHyperlink; 
     HtmlEdit uIUsernameEdit = this.UILogInWindowsInternetWindow.UILogInDocument1.UIUsernameEdit; 
     HtmlEdit uIPasswordEdit = this.UILogInWindowsInternetWindow.UILogInDocument1.UIPasswordEdit; 
     #endregion 

     // Go to web page 'http://localhost:15856/WebSite1/' 
     uILogInWindowsInternetWindow.NavigateToUrl(new System.Uri(this.RecordedMethodParams.UILogInWindowsInternetWindowUrl)); 

     // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.) 
     Playback.PlaybackSettings.ContinueOnError = true; 

     // Mouse hover 'Log In' link at (1, 1) 
     Mouse.Click(uILogInHyperlink); 

     // Reset flag to ensure that play back stops if there is an error. 
     Playback.PlaybackSettings.ContinueOnError = false; 

     // Type 'test' in 'Username:' text box 
     uIUsernameEdit.Text = this.RecordedMethodParams.UIUsernameEditText; 

     // The following element is no longer available: IE web control; Process Id [6320], window handle [3168166] 

     // Type '********' in 'Password:' text box 
     uIPasswordEdit.Password = this.RecordedMethodParams.UIPasswordEditPassword; 

     // The following element is no longer available: IE web control; Process Id [6320], window handle [3168166] 
} 
+1

這個安全補丁的bug可能是問題嗎? http://stackoverflow.com/questions/18900119/cannot-perform-click-on-the-hidden-control-visual-studio-2012-only – yonitdm

+0

@yonitdm即VS 2012不VS 2010 2010 –

+0

@yonitdm顯然這是不只是一個2012年的問題,感謝您的鏈接,添加它作爲答案,我會給你投票。 –

回答

1

這是鏈接到了9月發佈的Internet Explorer的修補程序的問題。

KB2870699

這會影響VS2010和VS2012。

微軟發佈了一個補丁來糾正VS2012的問題(我已經證實它解決了我的問題)。

http://blogs.msdn.com/b/visualstudioalm/archive/2013/09/17/coded-ui-mtm-issues-on-internet-explorer-with-kb2870699.aspx

目前用於VS2010唯一的解決方法是卸載補丁(KB2870699);然而,就像任何類型的安全補丁一樣,您需要仔細考慮是否確保在給定情況下執行安全操作。

編輯:這不是一個有趣的錯誤,我要處理。我剛剛從VS2010升級到VS2012,突然之間,我發現以前沒有任何功能正常的CodedUI測試工作。我認爲這是VS2012的一個問題,並且在一天中最好的一段時間裏,我的頭撞牆後,我發現這是一個補丁問題。在我的系統上安裝補丁的同時,我升級到2012年的確是我的運氣。美好時光!

+1

yeh它是一個真正的痛苦處理,起初我認爲這是一個自動代碼生成的問題,所以我嘗試了幾個小時手動編碼,它仍然保持失敗大聲笑 –

0

我與我的編碼UI測試有同樣的問題。這是一個問題與VS-2012我想,我試過每一個更新(安裝/卸載他們和一切..)沒有任何工作。 我試過VS-2013 Ultimate它工作。

-1

您可以使用異常處理來捕獲錯誤,同時仍然不會使測試失敗。

該測試失敗,因爲在執行點擊操作時,控件被隱藏。

try 
{ 
    //your code goes here 
} 
catch(FailedToPerformActionOnHiddenControlException e) 
{ 
    Console.WriteLine(e.Message); 
} 
相關問題