我試圖在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]
}
這個安全補丁的bug可能是問題嗎? http://stackoverflow.com/questions/18900119/cannot-perform-click-on-the-hidden-control-visual-studio-2012-only – yonitdm
@yonitdm即VS 2012不VS 2010 2010 –
@yonitdm顯然這是不只是一個2012年的問題,感謝您的鏈接,添加它作爲答案,我會給你投票。 –