当前位置:网站首页>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
边栏推荐
- I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
- 程序员远程办公喜忧参半| 社区征文
- vim正确加区间注释
- PostgreSQL users cannot create table configurations by themselves
- Katalon framework tests web (XXI) to obtain element attribute assertions
- 渗透实战-SQLServer提权
- My opinion on how to effectively telecommute | community essay solicitation
- 毕业三年,远程半年 | 社区征文
- Mindmanager2022 efficient and easy to use office mind map MindManager
- “软硬皆施”,助力建成新型云计算数据中心
猜你喜欢

Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡

Getting started with the go language is simple: go implements the Caesar password

idea修改主体颜色

AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving

三年进账35.31亿,这个江西老表要IPO了

Pointer array and array pointer

Detailed explanation of PPTC self recovery fuse

SQL statement strengthening exercise (MySQL 8.0 as an example)

Perf simple process for multithreaded profile

2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
随机推荐
用于TCP协议交互的TCPClientDemo
Rhcsa-- day one
基于PHP的轻量企业销售管理系统
SQL语句加强练习(MySQL8.0为例)
Katalon中控件的参数化
三年进账35.31亿,这个江西老表要IPO了
Object oriented -- encapsulation, inheritance, polymorphism
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
I Build a simple microservice project
Tcpclientdemo for TCP protocol interaction
ctf-pikachu-CSRF
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Msgraphmailbag - search only driveitems of file types
Storage of MySQL database
My opinion on how to effectively telecommute | community essay solicitation
Evolution of MySQL database architecture
"Implement both software and hardware" to help build a new cloud computing data center
Global exposure and roller shutter exposure of industrial cameras
vim映射命令
线程常用的方法