当前位置:网站首页>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
边栏推荐
- 选择排序与冒泡排序模板
- 【CSRF-01】跨站请求伪造漏洞基础原理及攻防
- MySQL one master multiple slaves + linear replication
- 【.NET+MQTT】.NET6 環境下實現MQTT通信,以及服務端、客戶端的雙邊消息訂閱與發布的代碼演示
- STM32外接DHT11显示温湿度
- Illustrated network: what is the hot backup router protocol HSRP?
- [PaddleSeg 源码阅读] PaddleSeg计算Dice
- vue多级路由嵌套怎么动态缓存组件
- Katalon框架测试web(二十六)自动发邮件
- Confession code collection, who says program apes don't understand romance
猜你喜欢
随机推荐
vue多级路由嵌套怎么动态缓存组件
【.NET+MQTT】.NET6 環境下實現MQTT通信,以及服務端、客戶端的雙邊消息訂閱與發布的代碼演示
Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
Idea modify body color
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
Perf simple process for multithreaded profile
[paddleseg source code reading] paddleseg custom data class
[paddleseg source code reading] paddleseg calculates Miou
【微服务|openfeign】feign的两种降级方式|Fallback|FallbackFactory
毕业设计:设计秒杀电商系统
Smart subway | cloud computing injects wisdom into urban subway transportation
1289_ Implementation analysis of vtask suspend() interface in FreeRTOS
【华为云IoT】读书笔记之《万物互联:物联网核心技术与安全》第3章(上)
[Yugong series] go teaching course 002 go language environment installation in July 2022
Katalon中控件的参数化
Is it safe to buy insurance for your children online? Do you want to buy a million dollar medical insurance for your children?
Penetration practice - sqlserver empowerment
Go 语言入门很简单:Go 实现凯撒密码