文章目录
1 参数化测试对象
可以参考Katalon的说明:
https://docs.katalon.com/katalon-studio/docs/parameterize-web-objects.html#example
1.1 参数化测试对象(Parameterize Web Test Objects and their properties)
-
Attributes
如果要把其中的text
作为参数化属性,把text
的vlaue
修改为${textcontent}
此时表示这个属性为动态的,并且关联的动态变量的名字为textcontent
-
XPath
//li[@role = 'option' and (text() = '${textcontent}' or . = '${textcontent}')]
1.2 使用参数对象(Using the parameterized test objects)
1.2.1 Manual View
在测试步骤中,添加测试对象时,按照如下设置变量:
1.2.2 Script View
WebUI.click(findTestObject('obj_xxx/li_option_text_X', [('textcontent') : optioncontent]))
2 运行时元素对象添加属性
2.1 添加测试对象
元素对象(Test Object),固定的属性保留(如:tag),可能会变化的去勾选(如:title)
2.2 为测试对象添加属性
注意:import com.kms.katalon.core.testobject.ConditionType
在脚本中为元素添加title属性:
import com.kms.katalon.core.testobject.ConditionType
findTestObject('obj_feature_xxx/Page_Client/SelectorType/li_option_X').addProperty('title', ConditionType.EQUALS, '用户')
新建测试对象,并为元素对象添加属性:
import com.kms.katalon.core.testobject.ConditionType
WebUI.click(new TestObject().addProperty("text", ConditionType.EQUALS, "服务"))
WebUI.setText(new TestObject().addProperty("xpath", ConditionType.EQUALS, "你的xpath表达式"), '张三')