在完成前面的代码编写后,编译整个项目,然后可以通过配置项目中的"Configuration.XML"文件,在QTP录制和测试运行TrackBar控件的过程中使用这个Custom Server的逻辑。
(1)双击打开如图18.7所示的Configuration.XML文件。
![]() |
图18.7 Configuration.XML文件 |
XML文件内容大致如下:
- <!-- Merge this XML content into file "<QuickTest Professional>dat SwfConfig.xml". -->
- <Control Type="System.Windows.Forms.TrackBar" >
- <CustomRecord>
- <Component>
- <Context>AUT</Context> <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName>
- <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName>
- </Component>
- </CustomRecord>
- <CustomReplay>
- <Component>
- <Context>AUT</Context> <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName>
- <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName>
- </Component>
- </CustomReplay>
- <!--<Settings>
- <Parameter Name="sample name">sample value</Parameter>
- </Settings> -->
- </Control>
(2)把其中的"<Control>"到"</Control>"的这段内容复制,然后,打开< QTP安装目录 >dat 中的SwfConfig.xml文件,把刚才复制的内容替换SwfConfig.xml文件中的"<Controls>"到"</Controls>"段内的内容。粘贴后,SwfConfig.xml文件的内容如下所示:
- <?xml version="1.0" encoding="UTF-8"?>
- <Controls>
- <Control Type="System.Windows.Forms.TrackBar" >
- <CustomRecord>
- <Component>
- <Context>AUT</Context> <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName>
- <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName>
- </Component>
- </CustomRecord>
- <CustomReplay>
- <Component>
- <Context>AUT</Context> <DllName>D:QTPMyWorkQuickTestCustomServer1QuickTestCustomServer1Bin QuickTestCustomServer1.dll</DllName>
- <TypeName>QuickTestCustomServer1.TrackBarCustomerServer </TypeName>
- </Component>
- </CustomReplay>
- <!--<Settings>
- <Parameter Name="sample name">sample value</Parameter>
- </Settings> -->
- </Control>
- </Controls>
(3)首先确保首先确保元素中包含了正确的Custom Server编译的DLL的正确路径,然后保存SwfConfig.xml文件