当前位置:网站首页>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
边栏推荐
猜你喜欢
MySQL maxscale realizes read-write separation
Penetration practice - sqlserver empowerment
Flink学习8:数据的一致性
Katalon框架测试web(二十六)自动发邮件
三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
用于TCP协议交互的TCPClientDemo
[paddleseg source code reading] paddleseg custom data class
三年进账35.31亿,这个江西老表要IPO了
Unity 绘制弹球和台球的运动轨迹
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
随机推荐
Illustrated network: what is the hot backup router protocol HSRP?
深度优先搜索简要讲解(附带基础题)
JS实现文字滚动 跑马灯效果
Katalon框架测试web(二十一)获取元素属性断言
10 reasons for not choosing to use free virtual hosts
Go 语言入门很简单:Go 实现凯撒密码
Rhcsa-- day one
Idea configuration 360zip open by default -- external tools
PostgreSQL users cannot create table configurations by themselves
Global exposure and roller shutter exposure of industrial cameras
图解网络:什么是热备份路由器协议HSRP?
How was my life in 2021
How to dynamically cache components in Vue multi-level route nesting
Brief explanation of depth first search (with basic questions)
Katalon中控件的参数化
【.NET+MQTT】.NET6 環境下實現MQTT通信,以及服務端、客戶端的雙邊消息訂閱與發布的代碼演示
Katalon framework test web (XXVI) automatic email
Zlmediakit compilation and webrtc push-pull flow testing
渗透实战-SQLServer提权
idea修改主体颜色