当前位置:网站首页>Parameterization of controls in katalon
Parameterization of controls in katalon
2022-07-04 04:11:00 【Spinach in spring】
background :
stay Katalon in , We go through Spy Grab control , Save in Object Repository in , The attribute of location is fixed
How about parameterizing these fixed positioning attributes , One way is through Xpath route , establish Test Object, another
The way is to put , Get the parameterization of the control positioning property
How to parameterize ?
Position attribute parameterization :
The so-called parameterization of control positioning properties , When this control is running , Dynamically give the specific value of the positioning attribute parameter , Such as text
Take a practical example
hypothesis APP There is a boot interface when starting , We need to choose from six interest tags
adopt Spy Mobile, We can see these interest tags , But it can't pass resource-id To distinguish between , because resource-id Are all the same
but Text It's different , Then we just need to put this Text Parameterize , During operation , To different Text value , So choose
Different controls
The captured controls are as follows , There are a total of six controls , among resource-id It's all the same
If we want to put one of them text Change to dynamic attribute
So now we need to take text Of vlaue It is amended as follows ${textname}
This indicates that this attribute is dynamic
And the name of the associated dynamic variable is testname
stay testcase Choose to use this control from the command in , Now open Test Object Input
In this Test Object Choose , There is a “Variables"
In this Variables You can create a variable in , At the same time, specify the value of the variable
The specified variable name , Need and Object Repository in , The variable names specified in the control properties should be consistent , It is set to "testname"
Now switch to Scripts in , You can see the detailed commands
Mobile.tap(findTestObject('tag_label', [('textname') : ' Military knowledge ']), 0)
Of course, this dynamic variable , Can support text , Numbers , perhaps Katalon The variables in the , Global variables, etc
If you can Variables in , Added a variable , If called label
here , The order becomes
Mobile.tap(findTestObject('tag_label', [('textname') : label]), 0)
In this way , We can run , Positioning properties of parameterized controls
that , At the beginning, six similar Text Control , We can do it in Object Repository, Keep only one
Instead of creating six similar controls , But only Text Different properties
If you click , You can pass different Text To dynamically locate
In script , That could be it
Mobile.tap(findTestObject('tag_label', [('textname') : ' Military knowledge ']), 0)
Mobile.tap(findTestObject('tag_label', [('textname') : ' Prehistoric behemoth ']), 0)
Mobile.tap(findTestObject('tag_label', [('textname') : ' Animal world ']), 0)
Mobile.tap(findTestObject('tag_label', [('textname') : ' Dinosaur world ']), 0)
If there are multiple dynamic attributes , It's the same thing
Such as adding resource-id It also becomes a dynamic attribute
So the order is as follows :
Mobile.tap(findTestObject('tag_label', [('textname') : ' Military knowledge ', ('resouceid') : 'com.mxr.dreambook:id/tv_tag']), 0)
Contents of this part ,Katalon Help for
You can refer to
https://docs.katalon.com/katalon-studio/docs/manage-test-object.html#test-objects-in-scripting-view
Positioning sequence :
Now let's think about these six similar TextView, It has passed Text Property to dynamically locate , But if you want to cycle through these six tabs
We must first create a value , similar [' Military knowledge ',' Dinosaur world ',' The world of animals '], Then iterate through
But if Text The content of... Has been modified , It will fail , And traversing through text arrays is a little cumbersome
We wonder whether we can traverse through sequences ?
At the beginning of observation , Think about whether you can pass instance Properties of
Because these six different TextView, Among them instance The properties of are 3,4,5,6,...
After the actual attempt, I found that it passed instance Unable to locate , because instance Attributes are not valid ,
We are xpath in , If you locate multiple , It can be done by [i] To distinguish between
You can do it in Object Repository in , Modify the positioning mode of that control to xpath
Xpath The attribute is
(//*[@class = 'android.widget.TextView' and @resource-id = 'com.mxr.dreambook:id/tv_tag'])[${index}]
among , So let's take this index As a dynamic parameter , Similar to the previous method
In script , We can go through 1 To 6 Click on this tab in a loop
// Select six interest Tags
for (def i : (1..6)) {
Mobile.tap(findTestObject('4Dapp/flashpage/tagselect/tag_Text', [('index') : i]), 5)
}
In this way, a dynamic loop is realized
Implementation of this part , You can refer to Katalon Explanation
https://docs.katalon.com/katalon-studio/docs/parameterize-webmobile-test-object-properties.html
Reference items
Katalon Official reference items
边栏推荐
- Objective C attribute keyword
- [PaddleSeg 源码阅读] PaddleSeg计算Dice
- 投资深度思考
- '2'>' 10'==true? How does JS perform implicit type conversion?
- JDBC advanced
- ctf-pikachu-XSS
- Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
- Zlmediakit compilation and webrtc push-pull flow testing
- 思考的小记录
- I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
猜你喜欢
SQL語句加强練習(MySQL8.0為例)
Activiti7 task service - process variables (setvariable and setvariablelocal)
Tcpclientdemo for TCP protocol interaction
postgresql 用户不能自己创建表格配置
Pytest multi process / multi thread execution test case
ctf-pikachu-XSS
Select sorting and bubble sorting template
1289_ Implementation analysis of vtask suspend() interface in FreeRTOS
透过JVM-SANDBOX源码,了解字节码增强技术原理
My opinion on how to effectively telecommute | community essay solicitation
随机推荐
"Implement both software and hardware" to help build a new cloud computing data center
Flink学习8:数据的一致性
智慧地铁| 云计算为城市地铁交通注入智慧
渗透实战-SQLServer提权
laravel admin里百度编辑器自定义路径和文件名
There is a problem that the package cannot be parsed in the like project
Wechat official account web page authorization
01 qemu 启动编译好的镜像 VFS: Unable to mount root fs on unknown-block(0,0)
[paddleseg source code reading] paddleseg calculation dice
Objective C attribute keyword
2022-07-03: there are 0 and 1 in the array. Be sure to flip an interval. Flip: 0 becomes 1, 1 becomes 0. What is the maximum number of 1 after turning? From little red book. 3.13 written examination.
Pytest multi process / multi thread execution test case
vue多级路由嵌套怎么动态缓存组件
Flink学习6:编程模型
思考的小记录
Activiti7 task service - process variables (setvariable and setvariablelocal)
SQL語句加强練習(MySQL8.0為例)
毕业总结
I Build a simple microservice project
02 specific implementation of LS command