当前位置:网站首页>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
边栏推荐
- Confession code collection, who says program apes don't understand romance
- 华为云鲲鹏工程师培训(广西大学)
- Go 语言入门很简单:Go 实现凯撒密码
- Idea configuration 360zip open by default -- external tools
- 2022-07-03:数组里有0和1,一定要翻转一个区间,翻转:0变1,1变0。 请问翻转后可以使得1的个数最多是多少? 来自小红书。3.13笔试。
- 【愚公系列】2022年7月 Go教学课程 002-Go语言环境安装
- 图解网络:什么是热备份路由器协议HSRP?
- 函数计算异步任务能力介绍 - 任务触发去重
- Getting started with the go language is simple: go implements the Caesar password
- AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving
猜你喜欢

02 ls 命令的具体实现

Objective-C description method and type method

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.

Katalon framework test web (XXVI) automatic email

Wechat official account web page authorization
![[csrf-01] basic principle and attack and defense of Cross Site Request Forgery vulnerability](/img/46/cb5a10ffe3fcdffb7da68dbaef5b1f.png)
[csrf-01] basic principle and attack and defense of Cross Site Request Forgery vulnerability

Rhcsa-- day one

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

基于PHP的轻量企业销售管理系统
![[paddleseg source code reading] paddleseg custom data class](/img/88/37c535b371486db545abc392a685af.png)
[paddleseg source code reading] paddleseg custom data class
随机推荐
Katalon中控件的参数化
毕业设计:设计秒杀电商系统
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
Brief explanation of depth first search (with basic questions)
Exercices de renforcement des déclarations SQL (MySQL 8.0 par exemple)
Evolution of MySQL database architecture
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
Smart subway | cloud computing injects wisdom into urban subway transportation
透过JVM-SANDBOX源码,了解字节码增强技术原理
Wechat official account web page authorization
Reduce function under functools
01 qemu 启动编译好的镜像 VFS: Unable to mount root fs on unknown-block(0,0)
MySQL maxscale realizes read-write separation
hbuildx中夜神模拟器的配置以及热更新
Illustrated network: what is the hot backup router protocol HSRP?
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
The difference between bagging and boosting in machine learning
PostgreSQL users cannot create table configurations by themselves
Getting started with the go language is simple: go implements the Caesar password
01 QEMU starts the compiled image vfs: unable to mount root FS on unknown block (0,0)