以XML文件方式擴展QTP的.NET插件的問題

今天試了一下QTP的.NET插件,QTP的.NET插件對於解決.NET控件識別和測試問題非常重要,是測試.NET平臺程序必不可少的條件(包括測試.NET Windows Forms、.NET Web Forms、WPF控件)。.NET第三方控件或自定義的個性化控件的識別和測試問題可通過QTP的.NET插件提供的擴展模塊來解決。

QTP的.NET插件主要提供了兩種方式的擴展來支持個性化控件的測試:

(1).NET DLL:使用其爲VS.NET提供的Custom Server模板來創建用C#寫的DLL來支持個性化控件的測試。

(2)XML:使用XML文件來描述擴展。

第一種方法的好處是可以充分利用開發工具的優勢,第二種方法則相對更便捷,可隨時進行擴展,但是今天試用的結果是可實現錄製方面的擴展,在回放方面的擴展不能實現,不知道是不是還有什麼訣竅沒掌握,QTP提供的幫助文檔在這方面也比較有限。
在SwfConfig.xml文件中的擴展描述如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<Controls>
  <Control Type="MyWindowsControlLibrary1.UserControl1">
          <Settings>
                 <Parameter Name="ConfigPath">D:/Program Files/Mercury Interactive/QuickTest Professional/dat/ControlDefineXMLSample.XML
                 </Parameter>
          </Settings>
         <CustomRecord>
                 <Component>
                        <Context>AUT-XML</Context>
                 </Component>
          </CustomRecord>
          <CustomReplay>
                <Component>

                       <Context>AUT-XML</Context>
                 </Component>
          </CustomReplay>
  </Control>
</Controls>

ControlDefineXMLSample.XML的定義如下:
<?xml version="1.0" encoding="UTF-8"?>
<Customization>
       <Record>
              <Events>
                     <Event name="MouseDown" enabled="true">
                            <RecordedCommand name="MouseMove">
                                   <Parameter>                                
                                   EventArgs.X
                                  </Parameter>
                                   <Parameter lang="C#">
                                   Parameter = EventArgs.Y;
                                  </Parameter>
                            </RecordedCommand>
                     </Event>
              </Events>
       </Record>
       <Replay>
              <Methods>
                     <Method name="SetValue">                    
                      <Parameters>
                                   <Parameter type="int" name="X"/>
                                   <Parameter type="int" name="Y"/>
                            </Parameters>
                            <MethodBody>

                                   System.Windows.Forms.MessageBox.Show("Mouse Position at Record Time");

                            </MethodBody>
                     </Method>
              </Methods>
       </Replay>
</Customization>

基本上是按QTP的幫助文檔描述,以及它提供的一個小例子來寫的。如果完全按其在NETExtensibility.chm文件中的“Example of a Control Definition XML File”這一節的例子來寫則完全不能進行錄製方面的擴展,它的例子如下:

詳細:http://www.51qa.net/Item/804.aspx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章