0

TC1:01_UserManagement/登录

String u = WebUI.getAttribute(findTestObject('SignInPage/txt_username'), 'placeholder')

WebUI.setText(findTestObject('SignInPage/txt_username'), username)

String p = WebUI.getAttribute(findTestObject('SignInPage/txt_password'), 'placeholder')

CustomKeywords.'com.fcm.utilities.ClearTextField.ClearText'(findTestObject('SignInPage/txt_password'))

WebUI.setText(findTestObject('SignInPage/txt_password'), password)

WebUI.click(findTestObject('SignInPage/btn_signinButton'))

Map map = [:]
map.put('inlinetextofusername',u)
map.put('inlinetextofpassword',p)
map.each{ k, v -> println "${k}:${v}" }
return map;

测试用例2:

Map TC_1_called = WebUI.callTestCase(findTestCase('01_UserManagement/Login'), [('username') : 'Anna', ('password') : 'Analyst_2017',('inlinetextofusername'):'',('inlinetextofpassword'):''], 
    FailureHandling.STOP_ON_FAILURE)

println(TC_1_called[inlinetextofusername])

println(TC_1_called[inlinetextofpassword]

我收到以下错误:-

2017 年 12 月 11 日下午 4:31:40 - [错误] - 测试用例/01_UserManagement/注销失败,因为没有为测试用例定义变量“inlinetextofusername”。

如何在测试用例 1 中获取存储在 Map 中的值并在测试用例 2 中使用。

4

3 回答 3

1

If you want to pass values from one test case to another in Katalon Studio, you should pass these values from Test Case A to Test Case B

Imagine you have these test cases Log in test and Dashboard test and you need to pass username and email from Log in testto Dashboard test

Go to script mode in Log in test and at the end of script add this line of code

WebUI.callTestCase( findTestCase('Test Cases/dashboard test')  , [('username'): username, ('email'):email]  )

This will pass local variables username and email from Log in test script to dashboard test

Notice: before applying this method, you should create test case variables to the second test case dashboard test from variables tab beside script tab in the lower section of test case editor.

Hope this comes in handy

于 2020-01-11T12:14:31.950 回答
1
Map TC_1_called = WebUI.callTestCase(findTestCase('01_UserManagement/Login'), [('username') : 'Anna', ('password') : 'Analyst_2017',('map'):''], 
    FailureHandling.STOP_ON_FAILURE)

这将返回值..

于 2017-12-12T10:14:41.483 回答
-1

我在将具有随机值的变量传递给另一个测试用例时遇到问题。

解决方案:我用空字符串创建了一个全局变量,然后在我的 testCase_1 上设置了一个随机值的全局变量。我现在可以在不调用 testCase_1 的情况下将该全局变量调用到我的 testCase_2。但是您必须首先在您的测试套件上执行 testCase_1。

测试用例_1:

GlobalVariable.randomString = yourRandomValue

测试案例_2:

字符串变量FromTestCase_1 = GlobalVariable.randomString

截屏

于 2018-11-08T10:03:30.440 回答