2013-07-02 44 views
1

目前的場景只是原始應用程序的虛擬。我有一個表格,有2 textboxes,1 ErrorProviderbutton Validate。當文本框爲空時,單擊驗證,然後2個錯誤提供程序出現在文本框前分別表示input 1 missinginput 2 missing。下面是檢測ErrorProvider的錯誤消息

enter image description here

現在我自動化研究小組正在檢測ErrorProvider控件工具提示的形式。他們正在使用QTP。對這個測試方面知之甚少,我開始了我的分析。我在QTP上試過的是

SwfEdit("textbox1").GetErrorProviderText()但沒用。我總是得到空文本。

然後我決定用White框架來實現這個東西。我能夠得到errorProvider控件,但不知道如何獲取每個文本框的錯誤消息。這個代碼我寫到目前爲止

AutomationElement rootElement = AutomationElement.RootElement; 
var winCollection = rootElement.FindAll(TreeScope.Children, Condition.TrueCondition); 

var automationElement = (from AutomationElement n in winCollection where n.Current.Name == "Error Provider Test" select n).FirstOrDefault(); 

if (automationElement != null) 
{ 
    Condition propCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, "errorProviderInput", PropertyConditionFlags.IgnoreCase); 
} 

我不知道如何繼續進行,如果我是正確的道路上。我很樂意聽到新的想法,建議或指導來實現這一點。謝謝。

回答

0

我最終發現了問題的解決方案。

通過我的分析,我注意到QTP在閱讀.NET Framework 4.0或更高版本的控件時遇到了一些問題。

建議的解決方案:

  1. 一般QTP無法檢測.NET框架4.0版本,如果.NET框架是QTP安裝後,計算機上安裝。從頭開始的全新安裝可能有助於解決問題。卸載QTP和.Net框架,然後安裝.Net框架,然後安裝QTP)。

  2. 爲了手動解決問題,我們必須手動註冊2個DLL。它們是Mercury.QTP.Agent.dll和Mercury.QTP.WpfAgent.dll。按照以下步驟註冊dll。

    • 如果您使用的是64位操作系統,請安裝QTP_00709補丁。
    • 以管理員模式打開命令提示符。
    • 導航到Mercury.QTP.Agent.dll和Mercury.QTP.WpfAgent.dll放置的位置。
    • 類型

..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.Agent.dll

..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.WpfAgent.dll

希望它能幫助。