简体   繁体   English

如何为动态字段准备HP QTP / UFT脚本?

[英]How to Prepare HP QTP/UFT scripts for Dynamic Fields?

Required Help here to prepare HP UFT Test Scripts for Dynamically changing Input Fields on Selection. 在此处需要帮助以准备HP UFT测试脚本,以便在选择时动态更改输入字段。

Scenario: 场景:

i have 2 types of list items and it will display various fields based on selection. 我有2种类型的列表项,它将根据选择显示各种字段。 1.14 digit card - perform customer registration(different fields) 2.16 Digit Card - Perform Customer Registration(different fields) 1.14数字卡-执行客户注册(不同字段)2.16数字卡-执行客户注册(不同字段)

Can i use if condition or any other conditions to Prepare Keyword driven framework to prepare test scripts for above type of scenarios. 我是否可以使用条件或任何其他条件来准备关键字驱动的框架,以为上述类型的场景准备测试脚本。

Suppose for Login with 14 digit cards. 假设使用14位数字卡登录。

Browser("name:=Login Screen").Page("title:=Login Screen").List(html id:=cardtypes).Select "#1"
Browser("name:=Login Screen").Page("title:=Login Screen").WebEdit("html id:=userNameId").Set khuname
Browser("name:=Login Screen").Page("title:=Login Screen").WebEdit("html id:=passwordId").Set khpasswd
Browser().Page().WebButton().Click

After Click on Login then in Customer Registration only selected card type fields will display,Like this i want to write the code for entire application modules,please help me how can i prepare test scripts for this type of application. 单击“登录”后,在“客户注册”中仅显示选定的卡类型字段,就像我要编写整个应用程序模块的代码一样,请帮助我如何为该类型的应用程序准备测试脚本。

At this point without knowing the Fields type it's a bit hard to say. 在这一点上,不知道字段类型,这很难说。 It depends on Object Property Or Their Position 这取决于对象属性或它们的位置

Let say there are 10 fields for 14 digit Card Type and 15 fields for 16 digit card type. 假设有14个数字卡类型的10个字段和16个数字卡类型的15个字段。 and among them 5-6 are common then you can perform operation on them in Common place in your function. 并且其中5-6是通用的,则可以在功能中的“通用”位置对它们执行操作。 if there are some parts of changing in your Fields object property(like in name or htmlid etc then you can store then in OR making their property Regular expression Enabled. ) 如果您的Fields对象属性中有某些更改的地方(例如名称或htmlid等),则可以将它们存储在OR中,或者使其属性正则表达式Enabled。

As i've said, it depends on the property of your field objects And also on Other Factors. 正如我所说,这取决于您的字段对象的属性以及其他因素。

Noe if they are different also, you can create a function which entertains an array/Dictionary (This either at runtime You can provide The Array/Dictionary values or you can configure them to be read from either xml,txt,excel file and store those in an Array/Dictionary.) 如果它们也不同,则可以创建一个招待数组/字典的函数(可以在运行时提供Array / Dictionary值,也可以将它们配置为从xml,txt,excel文件中读取并存储这些值在数组/字典中。)

Keep first element of array/ or first key-value pair Dictionary to specify the card type & the rest for field values. 保留array /或first key-value pair Dictionary的第一个元素以指定卡类型,其余指定字段值。 And based upon that you can make decision & create your function. 在此基础上,您可以做出决定并创建功能。

Your function should look like following.for example using Array 您的函数应如下所示。例如使用Array

public function CardRegister(*****Pass Array/Dictionary Object****) { ' Let say array object is objArr 公共函数CardRegister(***** Pass Array / Dictionary Object ****){'假设数组对象为objArr

If (objArr(0)="14 Digit card") then 如果是(objArr(0)=“ 14 Digit card”),则

. Select Desired entry from Weblist 从网站列表中选择所需条目

' Perform 14 digit card registration here '在这里执行14位数字卡注册

Elseif (objArr(0)="16 Digit card") then Elseif(objArr(0)=“ 16 Digit card”)然后

. Select Desired entry from Weblist 从网站列表中选择所需条目

' Perform 16 digit card registration here '在这里执行16位数字卡注册

End If 万一

' If common fields are there then you canperform operation on then in Common are. 如果存在通用字段,则可以在通用字段上执行操作。

'*************** common Fields********** '***************公共字段**********

'----- Do something ' - - - 做一点事

'************* common Fields *********** '*************公共字段***********

' Click on Register button & then Validaet whether it's successful '单击注册按钮,然后单击Validaet是否成功

} }

Now you can Mention this CardRegister function as Keyword & either user 现在,您可以提及此CardRegister函数作为关键字和任一用户

1)Eval 1)评估和演示

or 要么

2) Execute 2)执行

to call your function as Keyword. 调用您的函数作为关键字。 (This Keyword can also be put in xml/txt/excel file & u can configure you way of calling the Function) (此关键字也可以放在xml / txt / excel文件中,并且您可以配置调用函数的方式)

This way you can implement. 这样您就可以实现。 I hope you have got an idea. 我希望你有个主意。 Let me know if you have concerns. 如果您有任何疑问,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM