time 
设为首页】【收藏本站
当前位置: 主页 > 程序设计 > .net > Visual Studio > VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)

时间:2011-03-03 23:09 点击:1155次 字体:[ ]




回顾

在之前我们介绍了如何用VS2010UI测试功能创建一个简单的示例,大致描述了如何使用编码的UI测试进行录制和回放,在这章会着重描述VS2010是如何录制操作,并且生成代码,以及初步介绍如何通过自己写代码的方式进行测试。

 

内容简介

在上一章我们已经介绍过,建立一个编码的UI测试CodedUITest1.cs,录制完成之后,会自动生成一个UIMap1.uitest文件

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

1:录制完成后自动生成的UIMap1.uitest文件

事实上,在录制过程中起着关键作用的并非是CodedUITest1.cs,而是UIMap1.uitest,在录制过程中的所有代码都是生成在UIMap1.uitest,所有对于界面的操作,测试的判断也是在UIMap1.uitest文件完成,CodedUITest1.cs仅仅只是调用UIMap1.uitest中的方法(换言之只是个躯壳,编码的UI测试的灵魂还是在UIMap1.uitest

 

明白此点之后,接下来我们只需着重研究研究UIMap1.uitest即可,看看他是如何录制并生成代码的

 

注:这一章的内容可能较之第一章比较难,在阅读的时候可尽量使用VS2010进行操作,便于理解。由于本章内容较长,分为两个部分,上部分介绍原理,下部分介绍通过修改UIMap1.uitest控制操作步骤代码的生成,预计在周六或者周日发出

 

UIMap的录制与生成

首先我们新建一个测试项目

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

2:新建项目

 

建成之后,(可以看到系统自动默认生成了一个UnitTest.cs,我们可以先将它删除),右击该项目,选择添加à添加新项(注意,不是添加测试,是添加新项),在新项中选择Coded UI Test Map(编码的UI测试映射)

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

3:添加编码的UI测试映射

 

现在我们建立了一个UIMap1.uitest(可以看到这个UIMap1.uitest还没有生成UIMap1.csUIMap1.Designer.cs

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

4UIMap1.uitest

 

可以双击打开UIMap1.uitest,文件里面没有什么特殊的内容

<?xml version="1.0"?>

<UITest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="" Id="3efe829a-76df-439e-af0d-8d5c62727a1e" AssemblyVersion="10.0.21008.0" Version="1.0" xmlns="http://schemas.microsoft.com/VisualStudio/TeamTest/UITest/2010">

</UITest>

 

右击该UIMap1.uitest,选则Edit With Coded UI Test Builder(使用编码的UI测试生成器进行编辑),接下来会弹出录制操作用的生成器

 

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

5Edit With Coded UI Test Builder

  

我们还是按照上一中使用的示例程序和操作步骤进行录制四个方法InputErrorUidPwd()AssertErrorWinow()InputRightUidPwd()AssertRightWinow(),(可再添加一个方法CloseWindow(),关闭这个示例程序,上一章没有提到)操作完毕之后,生成代码,我们可以看到UIMap1.csUIMap1.Designer.cs已经自动生成,而实际有生成代码的文件为UIMap1.uitestUIMap1.Designer.csUIMap1.cs则为空

 

现在可以一个个进去看看生成的代码(注:由于录制过程中的操作步骤每个人都可能有细微差别,例如点击坐标,这里我录的示例和大家实验的时候自己录的可能存在一些区别,你懂的)

 

首先是UIMap1.uitest,大家可以看到这里的代码实在是多得看不清,如果觉得阅读比较困难,可以跳过此段,先看看解释说明,然后再回来看

 

UIMap.uitest
  1 <?xml version="1.0"?>
  2 <UITest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="" Id="3efe829a-76df-439e-af0d-8d5c62727a1e" AssemblyVersion="10.0.21008.0" Version="1.0" xmlns="http://schemas.microsoft.com/VisualStudio/TeamTest/UITest/2010">
  3   <Configuration>
  4     <Group Name="IE">
  5       <Setting Name="Version" Value="8.0.6001.18702" WarningLevel="1" />
  6       <Setting Name="InformationBar" WarningLevel="1" />
  7       <Setting Name="AutoCompletePassword" WarningLevel="1" />
  8       <Setting Name="AutoCompleteForm" Value="no" WarningLevel="1" />
  9       <Setting Name="DefaultBrowser" Value="IEXPLORE.EXE" WarningLevel="1" />
 10       <Setting Name="PopupBlocker" Value="1" WarningLevel="1" />
 11       <Setting Name="TabbedBrowsing" Value="0" WarningLevel="2" />
 12       <Setting Name="InternetZoneSecurity" Value="66816" WarningLevel="2" />
 13       <Setting Name="IntranetZoneSecurity" Value="69632" WarningLevel="2" />
 14       <Setting Name="TrustedZoneSecurity" Value="70912" WarningLevel="2" />
 15       <Setting Name="RestrictedZoneSecurity" Value="73728" WarningLevel="2" />
 16       <Setting Name="PhishingFilter" WarningLevel="1" />
 17       <Setting Name="EnhancedSecurityConfiguration" WarningLevel="1" />
 18     </Group>
 19     <Group Name="OS">
 20       <Setting Name="Name" Value="Microsoft Windows XP Professional" WarningLevel="2" />
 21       <Setting Name="Version" Value="Microsoft Windows NT 5.1.2600 Service Pack 3" WarningLevel="2" />
 22       <Setting Name="IsUserAdmin" Value="True" WarningLevel="2" />
 23       <Setting Name="Is64BitOperatingSystem" Value="False" WarningLevel="2" />
 24       <Setting Name="IsTerminalServerSession" Value="False" WarningLevel="2" />
 25       <Setting Name="OSLanguage" Value="1033" WarningLevel="1" />
 26       <Setting Name="UserLocale" Value="1033" WarningLevel="1" />
 27       <Setting Name="DragFullWindows" Value="True" WarningLevel="2" />
 28       <Setting Name="ScreenResolutionWidth" Value="1440" WarningLevel="2" />
 29       <Setting Name="ScreenResolutionHeight" Value="900" WarningLevel="2" />
 30       <Setting Name="SystemDPIX" Value="96" WarningLevel="2" />
 31       <Setting Name="SystemDPIY" Value="96" WarningLevel="2" />
 32       <Setting Name="Aero" WarningLevel="1" />
 33       <Setting Name="UACEnabled" WarningLevel="2" />
 34       <Setting Name="UACPromptEnabled" WarningLevel="1" />
 35       <Setting Name="WindowsAccessibilityAPIVersion" Value="2.0" WarningLevel="1" />
 36     </Group>
 37     <Group Name="TechnologyManagers">
 38       <Setting Name="Web" WarningLevel="1" />
 39       <Setting Name="UIA" WarningLevel="1" />
 40     </Group>
 41   </Configuration>
 42   <InitializeActions />
 43   <ExecuteActions>
 44     <SetValueAction UIObjectName="UIMap1.UI系统登录Window.UITbx_uidWindow.UITbx_uidEdit">
 45       <ParameterName />
 46       <Value Encoded="false">errorUid</Value>
 47       <Type>String</Type>
 48     </SetValueAction>
 49     <SetValueAction UIObjectName="UIMap1.UI系统登录Window.UITbx_pwdWindow.UITbx_pwdEdit">
 50       <ParameterName />
 51       <Value Encoded="false">errorPwd</Value>
 52       <Type>String</Type>
 53     </SetValueAction>
 54     <MouseAction UIObjectName="UIMap1.UI系统登录Window.UI登录Window.UI登录Button">
 55       <ParameterName />
 56       <ModifierKeys>None</ModifierKeys>
 57       <IsGlobalHotkey>false</IsGlobalHotkey>
 58       <Location X="25" Y="6" />
 59       <WheelDirection>0</WheelDirection>
 60       <ActionType>Click</ActionType>
 61       <MouseButton>Left</MouseButton>
 62     </MouseAction>
 63     <TestStepMarkerAction MarkerInformation="InputErrorUidPwd">
 64       <ParameterName />
 65       <StepId>-1</StepId>
 66       <Direction>Start</Direction>
 67       <Outcome />
 68       <Disabled>false</Disabled>
 69       <WorkItemId>0</WorkItemId>
 70       <MarkerRegionType>Action</MarkerRegionType>
 71     </TestStepMarkerAction>
 72     <AssertAction UIObjectName="UIMap.UI提示Window.UI用户名或密码错误Window.UI用户名或密码错误Text">
 73       <ParameterName />
 74       <PropertyName>Exists</PropertyName>
 75       <ExpectedValue>True</ExpectedValue>
 76       <Type>Boolean</Type>
 77       <PropertyCondition>AreEqual</PropertyCondition>
 78     </AssertAction>
 79     <TestStepMarkerAction MarkerInformation="AssertErrorWinow">
 80       <ParameterName />
 81       <StepId>-1</StepId>
 82       <Direction>Start</Direction>
 83       <Outcome />
 84       <Disabled>false</Disabled>
 85       <WorkItemId>0</WorkItemId>
 86       <MarkerRegionType>Assertion</MarkerRegionType>
 87     </TestStepMarkerAction>
 88     <MouseAction UIObjectName="UIMap1.UI提示Window.UIOKWindow.UIOKButton">
 89       <ParameterName />
 90       <ModifierKeys>None</ModifierKeys>
 91       <IsGlobalHotkey>false</IsGlobalHotkey>
 92       <Location X="22" Y="19" />
 93       <WheelDirection>0</WheelDirection>
 94       <ActionType>Click</ActionType>
 95       <MouseButton>Left</MouseButton>
 96     </MouseAction>
 97     <SetValueAction UIObjectName="UIMap1.UI系统登录Window.UITbx_uidWindow.UITbx_uidEdit">
 98       <ParameterName />
 99       <Value Encoded="false">Admin</Value>
100       <Type>String</Type>
101     </SetValueAction>
102     <SetValueAction UIObjectName="UIMap1.UI系统登录Window.UITbx_pwdWindow.UITbx_pwdEdit">
103       <ParameterName />
104       <Value Encoded="false">123456</Value>
105       <Type>String</Type>
106     </SetValueAction>
107     <MouseAction UIObjectName="UIMap1.UI系统登录Window.UI登录Window.UI登录Button">
108       <ParameterName />
109       <ModifierKeys>None</ModifierKeys>
110       <IsGlobalHotkey>false</IsGlobalHotkey>
111       <Location X="39" Y="8" />
112       <WheelDirection>0</WheelDirection>
113       <ActionType>Click</ActionType>
114       <MouseButton>Left</MouseButton>
115     </MouseAction>
116     <TestStepMarkerAction MarkerInformation="InputRightUidPwd">
117       <ParameterName />
118       <StepId>-1</StepId>
119       <Direction>Start</Direction>
120       <Outcome />
121       <Disabled>false</Disabled>
122       <WorkItemId>0</WorkItemId>
123       <MarkerRegionType>Action</MarkerRegionType>
124     </TestStepMarkerAction>
125     <AssertAction UIObjectName="UIMap.UI提示Window.UI用户名或密码错误Window.UI登陆成功Text">
126       <ParameterName />
127       <PropertyName>Exists</PropertyName>
128       <ExpectedValue>True</ExpectedValue>
129       <Type>Boolean</Type>
130       <PropertyCondition>AreEqual</PropertyCondition>
131     </AssertAction>
132     <TestStepMarkerAction MarkerInformation="AssertRightWinow">
133       <ParameterName />
134       <StepId>-1</StepId>
135       <Direction>Start</Direction>
136       <Outcome />
137       <Disabled>false</Disabled>
138       <WorkItemId>0</WorkItemId>
139       <MarkerRegionType>Assertion</MarkerRegionType>
140     </TestStepMarkerAction>
141     <MouseAction UIObjectName="UIMap1.UI提示Window.UIOKWindow.UIOKButton">
142       <ParameterName />
143       <ModifierKeys>None</ModifierKeys>
144       <IsGlobalHotkey>false</IsGlobalHotkey>
145       <Location X="28" Y="13" />
146       <WheelDirection>0</WheelDirection>
147       <ActionType>Click</ActionType>
148       <MouseButton>Left</MouseButton>
149     </MouseAction>
150     <MouseAction UIObjectName="UIMap1.UI系统登录Window.UI系统登录TitleBar.UICloseButton">
151       <ParameterName />
152       <ModifierKeys>None</ModifierKeys>
153       <IsGlobalHotkey>false</IsGlobalHotkey>
154       <Location X="9" Y="11" />
155       <WheelDirection>0</WheelDirection>
156       <ActionType>Click</ActionType>
157       <MouseButton>Left</MouseButton>
158     </MouseAction>
159     <TestStepMarkerAction MarkerInformation="CloseWindow">
160       <ParameterName />
161       <StepId>-1</StepId>
162       <Direction>Start</Direction>
163       <Outcome />
164       <Disabled>false</Disabled>
165       <WorkItemId>0</WorkItemId>
166       <MarkerRegionType>Action</MarkerRegionType>
167     </TestStepMarkerAction>
168   </ExecuteActions>
169   <CleanupActions />
170   <OnErrorActions />
171   <Maps>
172     <UIMap Id="UIMap1">
173       <TopLevelWindows>
174         <TopLevelWindow ControlType="Window" Id="UI系统登录Window" FriendlyName="系统登录" SpecialControlType="None" SessionId="154362">
175           <TechnologyName>MSAA</TechnologyName>
176           <WindowTitles>
177             <WindowTitle>系统登录</WindowTitle>
178           </WindowTitles>
179           <SearchConfigurations>
180             <SearchConfiguration>VisibleOnly</SearchConfiguration>
181           </SearchConfigurations>
182           <AndCondition Id="SearchCondition">
183             <PropertyCondition Name="Name">系统登录</PropertyCondition>
184             <PropertyCondition Name="ClassName" Operator="Contains">WindowsForms10.Window</PropertyCondition>
185             <PropertyCondition Name="ControlType">Window</PropertyCondition>
186           </AndCondition>
187           <SupportLevel>0</SupportLevel>
188           <Descendants>
189             <UIObject ControlType="Window" Id="UITbx_uidWindow" FriendlyName="Tbx_uid" SpecialControlType="None">
190               <TechnologyName>MSAA</TechnologyName>
191               <WindowTitles>
192                 <WindowTitle>系统登录</WindowTitle>
193               </WindowTitles>
194               <SearchConfigurations>
195                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
196               </SearchConfigurations>
197               <AndCondition Id="SearchCondition">
198                 <PropertyCondition Name="ControlName">Tbx_uid</PropertyCondition>
199                 <PropertyCondition Name="ControlType">Window</PropertyCondition>
200               </AndCondition>
201               <SupportLevel>0</SupportLevel>
202               <Descendants>
203                 <UIObject ControlType="Edit" Id="UITbx_uidEdit" FriendlyName="Tbx_uid" SpecialControlType="None">
204                   <TechnologyName>MSAA</TechnologyName>
205                   <WindowTitles>
206                     <WindowTitle>系统登录</WindowTitle>
207                   </WindowTitles>
208                   <SearchConfigurations>
209                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
210                   </SearchConfigurations>
211                   <AndCondition Id="SearchCondition">
212                     <PropertyCondition Name="Name">密码 :</PropertyCondition>
213                     <PropertyCondition Name="ControlType">Edit</PropertyCondition>
214                   </AndCondition>
215                   <SupportLevel>0</SupportLevel>
216                   <Descendants />
217                 </UIObject>
218               </Descendants>
219             </UIObject>
220             <UIObject ControlType="Window" Id="UITbx_pwdWindow" FriendlyName="Tbx_pwd" SpecialControlType="None">
221               <TechnologyName>MSAA</TechnologyName>
222               <WindowTitles>
223                 <WindowTitle>系统登录</WindowTitle>
224               </WindowTitles>
225               <SearchConfigurations>
226                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
227               </SearchConfigurations>
228               <AndCondition Id="SearchCondition">
229                 <PropertyCondition Name="ControlName">Tbx_pwd</PropertyCondition>
230                 <PropertyCondition Name="ControlType">Window</PropertyCondition>
231               </AndCondition>
232               <SupportLevel>0</SupportLevel>
233               <Descendants>
234                 <UIObject ControlType="Edit" Id="UITbx_pwdEdit" FriendlyName="Tbx_pwd" SpecialControlType="None">
235                   <TechnologyName>MSAA</TechnologyName>
236                   <WindowTitles>
237                     <WindowTitle>系统登录</WindowTitle>
238                   </WindowTitles>
239                   <SearchConfigurations>
240                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
241                   </SearchConfigurations>
242                   <AndCondition Id="SearchCondition">
243                     <PropertyCondition Name="ControlType">Edit</PropertyCondition>
244                   </AndCondition>
245                   <SupportLevel>0</SupportLevel>
246                   <Descendants />
247                 </UIObject>
248               </Descendants>
249             </UIObject>
250             <UIObject ControlType="Window" Id="UI登录Window" FriendlyName="登录" SpecialControlType="None">
251               <TechnologyName>MSAA</TechnologyName>
252               <WindowTitles>
253                 <WindowTitle>系统登录</WindowTitle>
254               </WindowTitles>
255               <SearchConfigurations>
256                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
257               </SearchConfigurations>
258               <AndCondition Id="SearchCondition">
259                 <PropertyCondition Name="ControlName">Btn_Login</PropertyCondition>
260                 <PropertyCondition Name="ControlType">Window</PropertyCondition>
261               </AndCondition>
262               <SupportLevel>0</SupportLevel>
263               <Descendants>
264                 <UIObject ControlType="Button" Id="UI登录Button" FriendlyName="登录" SpecialControlType="None">
265                   <TechnologyName>MSAA</TechnologyName>
266                   <WindowTitles>
267                     <WindowTitle>系统登录</WindowTitle>
268                   </WindowTitles>
269                   <SearchConfigurations>
270                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
271                   </SearchConfigurations>
272                   <AndCondition Id="SearchCondition">
273                     <PropertyCondition Name="Name">登录</PropertyCondition>
274                     <PropertyCondition Name="ControlType">Button</PropertyCondition>
275                   </AndCondition>
276                   <SupportLevel>0</SupportLevel>
277                   <Descendants />
278                 </UIObject>
279               </Descendants>
280             </UIObject>
281             <UIObject ControlType="TitleBar" Id="UI系统登录TitleBar" FriendlyName="系统登录" SpecialControlType="None">
282               <TechnologyName>MSAA</TechnologyName>
283               <WindowTitles>
284                 <WindowTitle>系统登录</WindowTitle>
285               </WindowTitles>
286               <SearchConfigurations>
287                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
288               </SearchConfigurations>
289               <AndCondition Id="SearchCondition">
290                 <PropertyCondition Name="ControlType">TitleBar</PropertyCondition>
291               </AndCondition>
292               <SupportLevel>0</SupportLevel>
293               <Descendants>
294                 <UIObject ControlType="Button" Id="UICloseButton" FriendlyName="Close" SpecialControlType="None">
295                   <TechnologyName>MSAA</TechnologyName>
296                   <WindowTitles>
297                     <WindowTitle>系统登录</WindowTitle>
298                   </WindowTitles>
299                   <SearchConfigurations>
300                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
301                   </SearchConfigurations>
302                   <AndCondition Id="SearchCondition">
303                     <PropertyCondition Name="Name">Close</PropertyCondition>
304                     <PropertyCondition Name="ControlType">Button</PropertyCondition>
305                   </AndCondition>
306                   <SupportLevel>0</SupportLevel>
307                   <Descendants />
308                 </UIObject>
309               </Descendants>
310             </UIObject>
311           </Descendants>
312         </TopLevelWindow>
313         <TopLevelWindow ControlType="Window" Id="UI提示Window" FriendlyName="提示" SpecialControlType="None" SessionId="1203022">
314           <TechnologyName>MSAA</TechnologyName>
315           <WindowTitles>
316             <WindowTitle>提示</WindowTitle>
317           </WindowTitles>
318           <SearchConfigurations>
319             <SearchConfiguration>VisibleOnly</SearchConfiguration>
320           </SearchConfigurations>
321           <AndCondition Id="SearchCondition">
322             <PropertyCondition Name="Name">提示</PropertyCondition>
323             <PropertyCondition Name="ClassName">#32770</PropertyCondition>
324             <PropertyCondition Name="ControlType">Window</PropertyCondition>
325           </AndCondition>
326           <SupportLevel>1</SupportLevel>
327           <Descendants>
328             <UIObject ControlType="Window" Id="UI用户名或密码错误Window" FriendlyName="用户名或密码错误!" SpecialControlType="None">
329               <TechnologyName>MSAA</TechnologyName>
330               <WindowTitles>
331                 <WindowTitle>提示</WindowTitle>
332               </WindowTitles>
333               <SearchConfigurations>
334                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
335               </SearchConfigurations>
336               <AndCondition Id="SearchCondition">
337                 <PropertyCondition Name="ControlId">65535</PropertyCondition>
338                 <PropertyCondition Name="ControlType">Window</PropertyCondition>
339               </AndCondition>
340               <SupportLevel>1</SupportLevel>
341               <Descendants>
342                 <UIObject ControlType="Text" Id="UI用户名或密码错误Text" FriendlyName="用户名或密码错误!" SpecialControlType="None">
343                   <TechnologyName>MSAA</TechnologyName>
344                   <WindowTitles>
345                     <WindowTitle>提示</WindowTitle>
346                   </WindowTitles>
347                   <SearchConfigurations>
348                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
349                   </SearchConfigurations>
350                   <AndCondition Id="SearchCondition">
351                     <PropertyCondition Name="Name">用户名或密码错误!</PropertyCondition>
352                     <PropertyCondition Name="ControlType">Text</PropertyCondition>
353                   </AndCondition>
354                   <SupportLevel>1</SupportLevel>
355                   <Descendants />
356                 </UIObject>
357                 <UIObject ControlType="Text" Id="UI登陆成功Text" FriendlyName="登陆成功!" SpecialControlType="None">
358                   <TechnologyName>MSAA</TechnologyName>
359                   <WindowTitles>
360                     <WindowTitle>提示</WindowTitle>
361                   </WindowTitles>
362                   <SearchConfigurations>
363                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
364                   </SearchConfigurations>
365                   <AndCondition Id="SearchCondition">
366                     <PropertyCondition Name="Name">登陆成功!</PropertyCondition>
367                     <PropertyCondition Name="ControlType">Text</PropertyCondition>
368                   </AndCondition>
369                   <SupportLevel>1</SupportLevel>
370                   <Descendants />
371                 </UIObject>
372               </Descendants>
373             </UIObject>
374             <UIObject ControlType="Window" Id="UIOKWindow" FriendlyName="OK" SpecialControlType="None">
375               <TechnologyName>MSAA</TechnologyName>
376               <WindowTitles>
377                 <WindowTitle>提示</WindowTitle>
378               </WindowTitles>
379               <SearchConfigurations>
380                 <SearchConfiguration>VisibleOnly</SearchConfiguration>
381               </SearchConfigurations>
382               <AndCondition Id="SearchCondition">
383                 <PropertyCondition Name="ControlId">2</PropertyCondition>
384                 <PropertyCondition Name="ControlType">Window</PropertyCondition>
385               </AndCondition>
386               <SupportLevel>0</SupportLevel>
387               <Descendants>
388                 <UIObject ControlType="Button" Id="UIOKButton" FriendlyName="OK" SpecialControlType="None">
389                   <TechnologyName>MSAA</TechnologyName>
390                   <WindowTitles>
391                     <WindowTitle>提示</WindowTitle>
392                   </WindowTitles>
393                   <SearchConfigurations>
394                     <SearchConfiguration>VisibleOnly</SearchConfiguration>
395                   </SearchConfigurations>
396                   <AndCondition Id="SearchCondition">
397                     <PropertyCondition Name="Name">OK</PropertyCondition>
398                     <PropertyCondition Name="ControlType">Button</PropertyCondition>
399                   </AndCondition>
400                   <SupportLevel>0</SupportLevel>
401                   <Descendants />
402                 </UIObject>
403               </Descendants>
404             </UIObject>
405           </Descendants>
406         </TopLevelWindow>
407       </TopLevelWindows>
408     </UIMap>
409   </Maps>
410   <ValueMap>
411     <ParameterList />
412   </ValueMap>
413 </UITest>

 

 

其实UIMap1.uitest这个XML的文件结构如下

<UITest>

           <Configuration>… </Configuration>

           <InitializeActions>…</InitializeActions>

           <ExecuteActions>…</ExecuteActions>

           <CleanupActions>…</CleanupActions>

           <OnErrorActions>…</OnErrorActions>

           <Maps>…</Maps>

           <ValueMap>…</ValueMap>  

</UITest>

这里做一个简单的说明:

Configuration:是对环境进行一个描述和配置,对测试几乎没有影响,可以忽略

InitializeActionsExecuteActionsCleanupActionsOnErrorAction:其中InitializeActions指初始化需要执行的操作,ExecuteActions指测试过程中的操作(目前我们所通过录制所生成的操作都默认放在ExecuteActions,大家现在可以回过去仔细看看ExecuteActions节点的内容),CleanupActions指测试完毕需要清理资源的Actions,而OnErrorAction则指代异常处理Actions

Maps:是我们需要关注的对象库,我们操作过程中所识别的所有控件都是会存放到这里的,对象识别我会在第三章的时候提及

ValueMap:是值映射,类似于参数记载,实际功能也不是特别大

 

在这些节点中,真正起到实际作用的是ActionsMaps

 

之后我们再来查看UIMap1.Designer.cs,同样,觉得会看晕的可直接跳过,之后回来再看

  

UIMap1.Designer.cs
  1 // ------------------------------------------------------------------------------
  2 //  <auto-generated>
  3 //      This code was generated by coded UI test builder.
  4 //      Version: 10.0.0.0
  5 //
  6 //      Changes to this file may cause incorrect behavior and will be lost if
  7 //      the code is regenerated.
  8 //  </auto-generated>
  9 // ------------------------------------------------------------------------------
 10 
 11 namespace TestProject1.UIMap1Classes
 12 {
 13     using System;
 14     using System.CodeDom.Compiler;
 15     using System.Collections.Generic;
 16     using System.Drawing;
 17     using System.Text.RegularExpressions;
 18     using System.Windows.Input;
 19     using Microsoft.VisualStudio.TestTools.UITest.Extension;
 20     using Microsoft.VisualStudio.TestTools.UITesting;
 21     using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
 22     using Microsoft.VisualStudio.TestTools.UnitTesting;
 23     using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
 24     using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;
 25     using MouseButtons = System.Windows.Forms.MouseButtons;
 26     
 27     
 28     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
 29     public partial class UIMap1
 30     {
 31         
 32         /// <summary>
 33         /// InputErrorUidPwd - Use 'InputErrorUidPwdParams' to pass parameters into this method.
 34         /// </summary>
 35         public void InputErrorUidPwd()
 36         {
 37             #region Variable Declarations
 38             WinEdit uITbx_uidEdit = this.UI系统登录Window.UITbx_uidWindow.UITbx_uidEdit;
 39             WinEdit uITbx_pwdEdit = this.UI系统登录Window.UITbx_pwdWindow.UITbx_pwdEdit;
 40             WinButton uI登录Button = this.UI系统登录Window.UI登录Window.UI登录Button;
 41             #endregion
 42 
 43             // Type 'errorUid' in 'Tbx_uid' text box
 44             uITbx_uidEdit.Text = this.InputErrorUidPwdParams.UITbx_uidEditText;
 45 
 46             // Type 'errorPwd' in 'Tbx_pwd' text box
 47             uITbx_pwdEdit.Text = this.InputErrorUidPwdParams.UITbx_pwdEditText;
 48 
 49             // Click '登录' button
 50             Mouse.Click(uI登录Button, new Point(256));
 51         }
 52         
 53         /// <summary>
 54         /// AssertErrorWinow - Use 'AssertErrorWinowExpectedValues' to pass parameters into this method.
 55         /// </summary>
 56         public void AssertErrorWinow()
 57         {
 58             #region Variable Declarations
 59             WinText uI用户名或密码错误Text = this.UI提示Window.UI用户名或密码错误Window.UI用户名或密码错误Text;
 60             #endregion
 61 
 62             // Verify that '用户名或密码错误!' label's property 'Exists' equals 'True'
 63             Assert.AreEqual(this.AssertErrorWinowExpectedValues.UI用户名或密码错误TextExists, uI用户名或密码错误Text.Exists);
 64         }
 65         
 66         /// <summary>
 67         /// InputRightUidPwd - Use 'InputRightUidPwdParams' to pass parameters into this method.
 68         /// </summary>
 69         public void InputRightUidPwd()
 70         {
 71             #region Variable Declarations
 72             WinButton uIOKButton = this.UI提示Window.UIOKWindow.UIOKButton;
 73             WinEdit uITbx_uidEdit = this.UI系统登录Window.UITbx_uidWindow.UITbx_uidEdit;
 74             WinEdit uITbx_pwdEdit = this.UI系统登录Window.UITbx_pwdWindow.UITbx_pwdEdit;
 75             WinButton uI登录Button = this.UI系统登录Window.UI登录Window.UI登录Button;
 76             #endregion
 77 
 78             // Click 'OK' button
 79             Mouse.Click(uIOKButton, new Point(2219));
 80 
 81             // Type 'Admin' in 'Tbx_uid' text box
 82             uITbx_uidEdit.Text = this.InputRightUidPwdParams.UITbx_uidEditText;
 83 
 84             // Type '123456' in 'Tbx_pwd' text box
 85             uITbx_pwdEdit.Text = this.InputRightUidPwdParams.UITbx_pwdEditText;
 86 
 87             // Click '登录' button
 88             Mouse.Click(uI登录Button, new Point(398));
 89         }
 90         
 91         /// <summary>
 92         /// AssertRightWinow - Use 'AssertRightWinowExpectedValues' to pass parameters into this method.
 93         /// </summary>
 94         public void AssertRightWinow()
 95         {
 96             #region Variable Declarations
 97             WinText uI登陆成功Text = this.UI提示Window.UI用户名或密码错误Window.UI登陆成功Text;
 98             #endregion
 99 
100             // Verify that '登陆成功!' label's property 'Exists' equals 'True'
101             Assert.AreEqual(this.AssertRightWinowExpectedValues.UI登陆成功TextExists, uI登陆成功Text.Exists);
102         }
103         
104         /// <summary>
105         /// CloseWindow
106         /// </summary>
107         public void CloseWindow()
108         {
109             #region Variable Declarations
110             WinButton uIOKButton = this.UI提示Window.UIOKWindow.UIOKButton;
111             WinButton uICloseButton = this.UI系统登录Window.UI系统登录TitleBar.UICloseButton;
112             #endregion
113 
114             // Click 'OK' button
115             Mouse.Click(uIOKButton, new Point(2813));
116 
117             // Click 'Close' button
118             Mouse.Click(uICloseButton, new Point(911));
119         }
120         
121         #region Properties
122         public virtual InputErrorUidPwdParams InputErrorUidPwdParams
123         {
124             get
125             {
126                 if ((this.mInputErrorUidPwdParams == null))
127                 {
128                     this.mInputErrorUidPwdParams = new InputErrorUidPwdParams();
129                 }
130                 return this.mInputErrorUidPwdParams;
131             }
132         }
133         
134         public virtual AssertErrorWinowExpectedValues AssertErrorWinowExpectedValues
135         {
136             get
137             {
138                 if ((this.mAssertErrorWinowExpectedValues == null))
139                 {
140                     this.mAssertErrorWinowExpectedValues = new AssertErrorWinowExpectedValues();
141                 }
142                 return this.mAssertErrorWinowExpectedValues;
143             }
144         }
145         
146         public virtual InputRightUidPwdParams InputRightUidPwdParams
147         {
148             get
149             {
150                 if ((this.mInputRightUidPwdParams == null))
151                 {
152                     this.mInputRightUidPwdParams = new InputRightUidPwdParams();
153                 }
154                 return this.mInputRightUidPwdParams;
155             }
156         }
157         
158         public virtual AssertRightWinowExpectedValues AssertRightWinowExpectedValues
159         {
160             get
161             {
162                 if ((this.mAssertRightWinowExpectedValues == null))
163                 {
164                     this.mAssertRightWinowExpectedValues = new AssertRightWinowExpectedValues();
165                 }
166                 return this.mAssertRightWinowExpectedValues;
167             }
168         }
169         
170         public UI系统登录Window UI系统登录Window
171         {
172             get
173             {
174                 if ((this.mUI系统登录Window == null))
175                 {
176                     this.mUI系统登录Window = new UI系统登录Window();
177                 }
178                 return this.mUI系统登录Window;
179             }
180         }
181         
182         public UI提示Window UI提示Window
183         {
184             get
185             {
186                 if ((this.mUI提示Window == null))
187                 {
188                     this.mUI提示Window = new UI提示Window();
189                 }
190                 return this.mUI提示Window;
191             }
192         }
193         #endregion
194         
195         #region Fields
196         private InputErrorUidPwdParams mInputErrorUidPwdParams;
197         
198         private AssertErrorWinowExpectedValues mAssertErrorWinowExpectedValues;
199         
200         private InputRightUidPwdParams mInputRightUidPwdParams;
201         
202         private AssertRightWinowExpectedValues mAssertRightWinowExpectedValues;
203         
204         private UI系统登录Window mUI系统登录Window;
205         
206         private UI提示Window mUI提示Window;
207         #endregion
208     }
209     
210     /// <summary>
211     /// Parameters to be passed into 'InputErrorUidPwd'
212     /// </summary>
213     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
214     public class InputErrorUidPwdParams
215     {
216         
217         #region Fields
218         /// <summary>
219         /// Type 'errorUid' in 'Tbx_uid' text box
220         /// </summary>
221         public string UITbx_uidEditText = "errorUid";
222         
223         /// <summary>
224         /// Type 'errorPwd' in 'Tbx_pwd' text box
225         /// </summary>
226         public string UITbx_pwdEditText = "errorPwd";
227         #endregion
228     }
229     
230     /// <summary>
231     /// Parameters to be passed into 'AssertErrorWinow'
232     /// </summary>
233     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
234     public class AssertErrorWinowExpectedValues
235     {
236         
237         #region Fields
238         /// <summary>
239         /// Verify that '用户名或密码错误!' label's property 'Exists' equals 'True'
240         /// </summary>
241         public bool UI用户名或密码错误TextExists = true;
242         #endregion
243     }
244     
245     /// <summary>
246     /// Parameters to be passed into 'InputRightUidPwd'
247     /// </summary>
248     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
249     public class InputRightUidPwdParams
250     {
251         
252         #region Fields
253         /// <summary>
254         /// Type 'Admin' in 'Tbx_uid' text box
255         /// </summary>
256         public string UITbx_uidEditText = "Admin";
257         
258         /// <summary>
259         /// Type '123456' in 'Tbx_pwd' text box
260         /// </summary>
261         public string UITbx_pwdEditText = "123456";
262         #endregion
263     }
264     
265     /// <summary>
266     /// Parameters to be passed into 'AssertRightWinow'
267     /// </summary>
268     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
269     public class AssertRightWinowExpectedValues
270     {
271         
272         #region Fields
273         /// <summary>
274         /// Verify that '登陆成功!' label's property 'Exists' equals 'True'
275         /// </summary>
276         public bool UI登陆成功TextExists = true;
277         #endregion
278     }
279     
280     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
281     public class UI系统登录Window : WinWindow
282     {
283         
284         public UI系统登录Window()
285         {
286             #region Search Criteria
287             this.SearchProperties[WinWindow.PropertyNames.Name] = "系统登录";
288             this.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains));
289             this.WindowTitles.Add("系统登录");
290             #endregion
291         }
292         
293         #region Properties
294         public UITbx_uidWindow UITbx_uidWindow
295         {
296             get
297             {
298                 if ((this.mUITbx_uidWindow == null))
299                 {
300                     this.mUITbx_uidWindow = new UITbx_uidWindow(this);
301                 }
302                 return this.mUITbx_uidWindow;
303             }
304         }
305         
306         public UITbx_pwdWindow UITbx_pwdWindow
307         {
308             get
309             {
310                 if ((this.mUITbx_pwdWindow == null))
311                 {
312                     this.mUITbx_pwdWindow = new UITbx_pwdWindow(this);
313                 }
314                 return this.mUITbx_pwdWindow;
315             }
316         }
317         
318         public UI登录Window UI登录Window
319         {
320             get
321             {
322                 if ((this.mUI登录Window == null))
323                 {
324                     this.mUI登录Window = new UI登录Window(this);
325                 }
326                 return this.mUI登录Window;
327             }
328         }
329         
330         public UI系统登录TitleBar UI系统登录TitleBar
331         {
332             get
333             {
334                 if ((this.mUI系统登录TitleBar == null))
335                 {
336                     this.mUI系统登录TitleBar = new UI系统登录TitleBar(this);
337                 }
338                 return this.mUI系统登录TitleBar;
339             }
340         }
341         #endregion
342         
343         #region Fields
344         private UITbx_uidWindow mUITbx_uidWindow;
345         
346         private UITbx_pwdWindow mUITbx_pwdWindow;
347         
348         private UI登录Window mUI登录Window;
349         
350         private UI系统登录TitleBar mUI系统登录TitleBar;
351         #endregion
352     }
353     
354     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
355     public class UITbx_uidWindow : WinWindow
356     {
357         
358         public UITbx_uidWindow(UITestControl searchLimitContainer) : 
359                 base(searchLimitContainer)
360         {
361             #region Search Criteria
362             this.SearchProperties[WinWindow.PropertyNames.ControlName] = "Tbx_uid";
363             this.WindowTitles.Add("系统登录");
364             #endregion
365         }
366         
367         #region Properties
368         public WinEdit UITbx_uidEdit
369         {
370             get
371             {
372                 if ((this.mUITbx_uidEdit == null))
373                 {
374                     this.mUITbx_uidEdit = new WinEdit(this);
375                     #region Search Criteria
376                     this.mUITbx_uidEdit.SearchProperties[WinEdit.PropertyNames.Name] = "密码 :";
377                     this.mUITbx_uidEdit.WindowTitles.Add("系统登录");
378                     #endregion
379                 }
380                 return this.mUITbx_uidEdit;
381             }
382         }
383         #endregion
384         
385         #region Fields
386         private WinEdit mUITbx_uidEdit;
387         #endregion
388     }
389     
390     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
391     public class UITbx_pwdWindow : WinWindow
392     {
393         
394         public UITbx_pwdWindow(UITestControl searchLimitContainer) : 
395                 base(searchLimitContainer)
396         {
397             #region Search Criteria
398             this.SearchProperties[WinWindow.PropertyNames.ControlName] = "Tbx_pwd";
399             this.WindowTitles.Add("系统登录");
400             #endregion
401         }
402         
403         #region Properties
404         public WinEdit UITbx_pwdEdit
405         {
406             get
407             {
408                 if ((this.mUITbx_pwdEdit == null))
409                 {
410                     this.mUITbx_pwdEdit = new WinEdit(this);
411                     #region Search Criteria
412                     this.mUITbx_pwdEdit.WindowTitles.Add("系统登录");
413                     #endregion
414                 }
415                 return this.mUITbx_pwdEdit;
416             }
417         }
418         #endregion
419         
420         #region Fields
421         private WinEdit mUITbx_pwdEdit;
422         #endregion
423     }
424     
425     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
426     public class UI登录Window : WinWindow
427     {
428         
429         public UI登录Window(UITestControl searchLimitContainer) : 
430                 base(searchLimitContainer)
431         {
432             #region Search Criteria
433             this.SearchProperties[WinWindow.PropertyNames.ControlName] = "Btn_Login";
434             this.WindowTitles.Add("系统登录");
435             #endregion
436         }
437         
438         #region Properties
439         public WinButton UI登录Button
440         {
441             get
442             {
443                 if ((this.mUI登录Button == null))
444                 {
445                     this.mUI登录Button = new WinButton(this);
446                     #region Search Criteria
447                     this.mUI登录Button.SearchProperties[WinButton.PropertyNames.Name] = "登录";
448                     this.mUI登录Button.WindowTitles.Add("系统登录");
449                     #endregion
450                 }
451                 return this.mUI登录Button;
452             }
453         }
454         #endregion
455         
456         #region Fields
457         private WinButton mUI登录Button;
458         #endregion
459     }
460     
461     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
462     public class UI系统登录TitleBar : WinTitleBar
463     {
464         
465         public UI系统登录TitleBar(UITestControl searchLimitContainer) : 
466                 base(searchLimitContainer)
467         {
468             #region Search Criteria
469             this.WindowTitles.Add("系统登录");
470             #endregion
471         }
472         
473         #region Properties
474         public WinButton UICloseButton
475         {
476             get
477             {
478                 if ((this.mUICloseButton == null))
479                 {
480                     this.mUICloseButton = new WinButton(this);
481                     #region Search Criteria
482                     this.mUICloseButton.SearchProperties[WinButton.PropertyNames.Name] = "Close";
483                     this.mUICloseButton.WindowTitles.Add("系统登录");
484                     #endregion
485                 }
486                 return this.mUICloseButton;
487             }
488         }
489         #endregion
490         
491         #region Fields
492         private WinButton mUICloseButton;
493         #endregion
494     }
495     
496     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
497     public class UI提示Window : WinWindow
498     {
499         
500         public UI提示Window()
501         {
502             #region Search Criteria
503             this.SearchProperties[WinWindow.PropertyNames.Name] = "提示";
504             this.SearchProperties[WinWindow.PropertyNames.ClassName] = "#32770";
505             this.WindowTitles.Add("提示");
506             #endregion
507         }
508         
509         #region Properties
510         public UI用户名或密码错误Window UI用户名或密码错误Window
511         {
512             get
513             {
514                 if ((this.mUI用户名或密码错误Window == null))
515                 {
516                     this.mUI用户名或密码错误Window = new UI用户名或密码错误Window(this);
517                 }
518                 return this.mUI用户名或密码错误Window;
519             }
520         }
521         
522         public UIOKWindow UIOKWindow
523         {
524             get
525             {
526                 if ((this.mUIOKWindow == null))
527                 {
528                     this.mUIOKWindow = new UIOKWindow(this);
529                 }
530                 return this.mUIOKWindow;
531             }
532         }
533         #endregion
534         
535         #region Fields
536         private UI用户名或密码错误Window mUI用户名或密码错误Window;
537         
538         private UIOKWindow mUIOKWindow;
539         #endregion
540     }
541     
542     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
543     public class UI用户名或密码错误Window : WinWindow
544     {
545         
546         public UI用户名或密码错误Window(UITestControl searchLimitContainer) : 
547                 base(searchLimitContainer)
548         {
549             #region Search Criteria
550             this.SearchProperties[WinWindow.PropertyNames.ControlId] = "65535";
551             this.WindowTitles.Add("提示");
552             #endregion
553         }
554         
555         #region Properties
556         public WinText UI用户名或密码错误Text
557         {
558             get
559             {
560                 if ((this.mUI用户名或密码错误Text == null))
561                 {
562                     this.mUI用户名或密码错误Text = new WinText(this);
563                     #region Search Criteria
564                     this.mUI用户名或密码错误Text.SearchProperties[WinText.PropertyNames.Name] = "用户名或密码错误!";
565                     this.mUI用户名或密码错误Text.WindowTitles.Add("提示");
566                     #endregion
567                 }
568                 return this.mUI用户名或密码错误Text;
569             }
570         }
571         
572         public WinText UI登陆成功Text
573         {
574             get
575             {
576                 if ((this.mUI登陆成功Text == null))
577                 {
578                     this.mUI登陆成功Text = new WinText(this);
579                     #region Search Criteria
580                     this.mUI登陆成功Text.SearchProperties[WinText.PropertyNames.Name] = "登陆成功!";
581                     this.mUI登陆成功Text.WindowTitles.Add("提示");
582                     #endregion
583                 }
584                 return this.mUI登陆成功Text;
585             }
586         }
587         #endregion
588         
589         #region Fields
590         private WinText mUI用户名或密码错误Text;
591         
592         private WinText mUI登陆成功Text;
593         #endregion
594     }
595     
596     [GeneratedCode("Coded UITest Builder""10.0.30319.1")]
597     public class UIOKWindow : WinWindow
598     {
599         
600         public UIOKWindow(UITestControl searchLimitContainer) : 
601                 base(searchLimitContainer)
602         {
603             #region Search Criteria
604             this.SearchProperties[WinWindow.PropertyNames.ControlId] = "2";
605             this.WindowTitles.Add("提示");
606             #endregion
607         }
608         
609         #region Properties
610         public WinButton UIOKButton
611         {
612             get
613             {
614                 if ((this.mUIOKButton == null))
615                 {
616                     this.mUIOKButton = new WinButton(this);
617                     #region Search Criteria
618                     this.mUIOKButton.SearchProperties[WinButton.PropertyNames.Name] = "OK";
619                     this.mUIOKButton.WindowTitles.Add("提示");
620                     #endregion
621                 }
622                 return this.mUIOKButton;
623             }
624         }
625         #endregion
626         
627         #region Fields
628         private WinButton mUIOKButton;
629         #endregion
630     }
631 }
632 

 

 

UIMap1.Designer.cs这个文件结构如下

VS2010测试功能之旅:编码的UI测试(2)-操作动作的录制原理(上)_www.fengfly.com

6UIMap1.Designer.cs

 

我们可以用UIMap1.uitest上的内容和UIMap1.Designer.cs上的内容做个对比,可以明显的发现他们之间有一定的对应性,那么疑问就产生了,我们在录制的时候,究竟先生成UIMap1.uitest还是UIMap1.Designer.cs?在对界面操作的代码中,他们哪个起作用?

 

为了说明这个,就得提到编码的UI测试操作步骤的录制原理,这里会按步骤说明:

(1)     首先我们打开了录制生成器

(2)     使用录制生成器录制操作,对于每一个操作动作,录制生成器会根据你所进行的操作,解析被操作的对象(控件),并分析操作动作,并将对象(控件)的关键标识属性和操作动作按录制顺序存放在内存中

(3)     停止录制

(4)     点击“生成代码”按钮,录制生成器会读取之前放在内存中的对象(控件)的关键标识属性和操作动作按XML的形式存放在UIMap1.uitest

(5)     之后代码生成器通过解析UIMap1.uitest,再生成UIMap1.Designer.cs

然后进行回放的时候,真正在起作用其实的是UIMap1.Designer.csUIMap1.uitest的作用仅仅是用于生成UIMap1.Designer.cs

 

我想介绍到这里很多曾经使用过VS2010编码UI测试的朋友应该明白了,为什么自己在UIMap1.Designer.cs添加或者删除的代码,在打开录制生成器之后,重新点击“生成代码”,之前的修改就消失了,原因就是因为UIMap1.Designer.cs里面的代码是根据UIMap1.uitest生成的

 

因此,如果要想编写自定义代码,可以通过两种途径

(1)通过修改UIMap1.uitest来控制UIMap1.Designer.cs代码的生成

(2)将代码写到非UIMap1.Designer.cs文件的其他地方

  

在本章的第二部分,将介绍如何通过修改UIMap1.uitest来控制UIMap1.Designer.cs代码的生成,预计可能在本周六或者周日发布,敬请关注~

 

PS:如何调用UIMap1.Designer.cs中的方法,这个时候可以新建一个CodedUItest.cs,取消录制,写一个这样的调用即可

        [TestMethod]

        public void CodedUITestMethod1()

        {

            UIMap1Classes.UIMap1 uimap1 = new UIMap1Classes.UIMap1();

            uimap1.InputErrorUidPwd();

            uimap1.AssertErrorWinow();

            uimap1.InputRightUidPwd();

            uimap1.AssertRightWinow();

            uimap1.CloseWindow();

        }



本文地址 : http://www.fengfly.com/plus/view-196628-1.html
标签: 编码 VS2010 UI测试 测试功能
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码: