18.2.6 对QTP进行配置

在完成前面的代码编写后,编译整个项目,然后可以通过配置项目中的"Configuration.XML"文件,在QTP录制和测试运行TrackBar控件的过程中使用这个Custom Server的逻辑。

(1)双击打开如图18.7所示的Configuration.XML文件。

 
图18.7  Configuration.XML文件

XML文件内容大致如下:

  1. <!-- Merge this XML content into file "<QuickTest Professional>dat SwfConfig.xml". --> 
  2.   <Control Type="System.Windows.Forms.TrackBar" 
  3.     <CustomRecord
  4.       <Component
  5.         <Context>AUT</Context>        <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName
  6.         <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName
  7.       </Component
  8.     </CustomRecord
  9.     <CustomReplay
  10.       <Component
  11.         <Context>AUT</Context>        <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName
  12.         <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName
  13.       </Component
  14.     </CustomReplay
  15. <!--<Settings
  16.        <Parameter Name="sample name">sample value</Parameter
  17.     </Settings> --
  18.   </Control

(2)把其中的"<Control>"到"</Control>"的这段内容复制,然后,打开< QTP安装目录 >dat 中的SwfConfig.xml文件,把刚才复制的内容替换SwfConfig.xml文件中的"<Controls>"到"</Controls>"段内的内容。粘贴后,SwfConfig.xml文件的内容如下所示:

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <Controls
  3.   <Control Type="System.Windows.Forms.TrackBar" 
  4.     <CustomRecord
  5.       <Component
  6.         <Context>AUT</Context>        <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName
  7.         <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName
  8.       </Component
  9.     </CustomRecord
  10.     <CustomReplay
  11.       <Component
  12.         <Context>AUT</Context>        <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName
  13.         <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName
  14.       </Component
  15.     </CustomReplay
  16. <!--<Settings
  17.        <Parameter Name="sample name">sample value</Parameter
  18.     </Settings> --
  19.   </Control
  20. </Controls

(3)首先确保首先确保元素中包含了正确的Custom Server编译的DLL的正确路径,然后保存SwfConfig.xml文件

原文地址:https://www.cnblogs.com/gdg87813/p/10956297.html