自动化测试工具-Katalon Studio
Katalon 代码片段:
1)if(WebUI.verifyTextPresent(findTestObject('Page_Skin/p_Are you ok?'),10,FailureHandling.CONTINUE_ON_FAILURE)) 表达式未获取到true或者false值;
2) if(WebUI.waitForElementPresent(findTestObject('Page_Skin/Continue Seds'),10,FailureHandling.OPTIONAL)) 表达式可以获取到true或者false值;
3) 测试Demo:
WebUI.openBrowser('')
WebUI.navigateToUrl('https://www.hehe.org/')
WebUI.verifyElementVisible(findTestObject('Page_Skin_1cc4a1/span_LoginSign up'))
WebUI.click(findTestObject('Page_Skin_1cc4a1/span_LoginSign up'))
WebUI.setText(findTestObject('Page_SkinHehe_1cc4a1/input'), '207@ccwwwaa.com')
WebUI.setText(findTestObject('Page_SkinHehe_1cc4a1/input_1'), '123456')
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_LOGIN'))
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_Wrinkles, Texture, Pores'))
WebUI.click(findTestObject('Page_SkinHehe_e46d5e/span_Get Treatment'))
WebUI.click(findTestObject('Page_SkinHehe_e46d5e/span_Add Continue'))
WebUI.waitForPageLoad(5)
// Skin buy something flow
if(WebUI.waitForElementPresent(findTestObject('Page_SkinHehe_1cc4a1/radio3c'),
2,FailureHandling.OPTIONAL)) {
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/radio1a'))
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_Next'))
}else {
println 'ques radio1'
}
for(int i =0;i<10;i=i+1) {
if(WebUI.waitForElementPresent(findTestObject('Page_SkinHehe_1cc4a1/radio2b'),
2,FailureHandling.OPTIONAL)) {
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/radio2b'))
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_Next'))
}else {
println 'ques radio2b not shown'
}
if(WebUI.waitForElementPresent(findTestObject('Page_SkinHehe_1cc4a1/textarea'),
2,FailureHandling.OPTIONAL)) {
WebUI.setText(findTestObject('Page_SkinHehe_1cc4a1/textarea'), '0001')
if(WebUI.waitForElementPresent(findTestObject('Page_SkinHehe_1cc4a1/textarea2'),
2,FailureHandling.OPTIONAL)) {
WebUI.setText(findTestObject('Page_SkinHehe_1cc4a1/textarea2'), '0002')
}
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_Next'))
}else {
println 'ques textarea'
}
if(WebUI.waitForElementPresent(findTestObject('Page_SkinHehe_1cc4a1/checkbox1'),
2,FailureHandling.OPTIONAL)) {
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/checkbox1'))
WebUI.click(findTestObject('Page_SkinHehe_1cc4a1/span_Next'))
}else {
println 'ques cb textarea'
}
}