2013-04-17 31 views
0
public void RecordedMethod_Sample(int x) 
    { 
     #region Variable Declarations 
     HtmlCell uISALESREVENUECell = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UITblWrapperOnlineStorTable.UISALESREVENUECell; 
     HtmlImage uIImagegifbase64R0lGODImage = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UIImagegifbase64R0lGODImage; 
     HtmlHyperlink uIPostPurchase4Hyperlink = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UIPostPurchase4ReturnsCustom.UIPostPurchase4Hyperlink; 
     HtmlDiv uISalesRevenueByDataSoPane = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UISalesRevenueByDataSoPane; 
     #endregion 

     // 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 'SALES REVENUE' cell at (82, 27) 
     Mouse.Hover(uISALESREVENUECell, new Point(82, 27)); 

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

     // Click 'image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAA...' image 
     Mouse.Click(uIImagegifbase64R0lGODImage, new Point(139, 64)); 

     // 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 'Post Purchase4' link at (144, 19) 
     Mouse.Hover(uIPostPurchase4Hyperlink, new Point(144, 19)); 

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

     // Move 'Sales Revenue By Data Source' pane 
     Mouse.StartDragging(uISalesRevenueByDataSoPane, new Point(79, 15)); 
     Mouse.StopDragging(uISalesRevenueByDataSoPane, 224, -4); 
     string title = uISalesRevenueByDataSoPane.InnerText.ToString(); 
     if (title == "Sales Revenue By Data Source") 
     { 

     } 

while Executing Mouse.Hover(uISALESREVENUECell,new Point(82,27));它給出 錯誤 不支持指定的方法。 每當我試着執行它作爲測試用例,然後一切工作正常 同時通過自定義代碼執行它給上面提到的錯誤 任何人可以請幫我... 在此先感謝您的所有投入編碼的UI:在通過自定義代碼執行時具有記錄動作的測試用例失敗

+0

你可以發佈代碼,你調用'RecordedMethod_Sample'嗎? – Schaliasos

回答

0

「自定義代碼」是什麼意思?如果它意味着自定義控件,那麼錯誤可能是因爲自定義控件沒有被編寫爲支持編碼UI。爲了使自定義控件與編碼UI一起工作,它必須支持MSAA或UIA接口,或者獲得新代理機制的支持。

欲瞭解更多詳情,請嘗試網頁搜索Coded UI,MSAA和UIA。也看看這個博客http://blogs.msdn.com/b/visualstudioalm/archive/2012/05/24/coded-ui-test-new-extensibility-qfe.aspx

0

我有這個確切的問題。

最好的辦法是儘可能多地使用記錄器,然後在需要動態執行時只將這些東西從UI映射中移走,並且僅用於這些位。

讓錄音機爲您做好所有工作,並且在播放過程中您將獲得更好的可靠性。

相關問題