多测师是一家拥有先进的教学理念,强大的师资团队,业内好评甚多的接口自动化测试培训机构!

17727591462

联系电话

您现在所在位置:接口自动化测试培训 > 新闻资讯

以XML文件方式扩展QTP的.NET插件的问题-自动化测试

更新时间:2022-06-01 09:15:31 作者:多测师 浏览:211

       今天试了一下QTP的.NET插件,QTP的.NET插件对于解决.NET控件识别和测试问题非常重要,是测试.NET平台程序必不可少的条件(包括测试.NET Windows Forms、.NET Web Forms、WPF控件)。.NET第三方控件或自定义的个性化控件的识别和测试问题可通过QTP的.NET插件提供的扩展模块来解决。

以XML文件方式扩展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”这一节的例子来写则完全不能进行录制方面的扩展,它的例子如下:

<?xml version="1.0" encoding="UTF-8"?>

<Customization>

<Record>

<Events>

<Event name="MouseUp" enabled="true">

<RecordedCommand name="SetValue">

<Parameter>

Sender.Value

</Parameter>

<Parameter lang="C#">

String xy;

xy = EventArgs.X + ";" + EventArgs.Y;

Parameter = xy;

</Parameter>

</RecordedCommand>

</Event>

</Events>

</Record>

<Replay>

<Methods>

<Method name="SetValue">

<Parameters>

<Parameter type="int" name="Value"/>

<Parameter type="String" name="MousePosition"/>

</Parameters>

<MethodBody>

RtObject.Value = Value;

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

</MethodBody>

</Method>

</Methods>

</Replay>

</Customization>

       以上内容为大家介绍了自动化测试中的以XML文件方式扩展QTP的.NET插件的问题,本文由多测师亲自撰写,希望对大家有所帮助。了解更多自动化测试相关知识:https://www.aichudan.com/xwzx/

联系电话

17727591462

返回顶部