Can we pass a value generated in a test case to another test case as a input?

Chandrasekaran Ganapathy said:

Can we return multiple variables from one test case

I have the same issue. Have u deal with it?

Phan Ky Giang said:

Chandrasekaran Ganapathy said:

Can we return multiple variables from one test case

I have the same issue. Have u deal with it?

I think the easiest way to do that is a variable of type array, or map or similar. You can about arrays et al here:

http://docs.groovy-lang.org/latest/html/documentation/#_arrays

Phan Ky Giang said:

Chandrasekaran Ganapathy said:

Can we return multiple variables from one test case

I have the same issue. Have u deal with it?

Yes… You can create a HashMap and return the map…

Test Case :1
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

WebUI.openBrowser(’’)

WebUI.navigateToUrl(GlobalVariable.URL)

WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store/a_Log in’))

WebUI.setText(findTestObject(‘Reset Wishlist/Page_Your store. Login/input_Email_Email’), ‘johndeo@gmail.com’)

WebUI.setEncryptedText(findTestObject(‘Reset Wishlist/Page_Your store. Login/input_Password_Password’), ‘aeHFOx8jV/A=’)

WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store. Login/input_Forgot password_button-1’))

WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store/span_Wishlist’))

if (WebUI.verifyElementPresent(findTestObject(‘Reset Wishlist/Page_Your store. Wishlist/input_245.00_updatecart’),
5, FailureHandling.OPTIONAL) == true) {
while (WebUI.verifyElementPresent(findTestObject(‘Reset Wishlist/Page_Your store. Wishlist/input_Remove_removefromcart’),
5, FailureHandling.OPTIONAL) == true) {
WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store. Wishlist/input_Remove_removefromcart’))

    WebUI.click(findTestObject('Reset Wishlist/Page\_Your store. Wishlist/input\_245.00_updatecart'))  
}  
 
WebUI.verifyTextPresent('The wishlist is empty!', false)  

WebUI.navigateToUrl(GlobalVariable.URL)  

} else {
WebUI.navigateToUrl(GlobalVariable.URL)
}

WebUI.closeBrowser()

Test case :2
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

WebUI.callTestCase(findTestCase(‘Reset Wishlist’), [(GlobalVariable.Password) : GlobalVariable.Password, (GlobalVariable.Username) : GlobalVariable.Username],
FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store/input_245.00_button-2 add-to-w’))

WebUI.click(findTestObject(‘Reset Wishlist/Page_Your store/a_wishlist’))

WebUI.verifyElementText(findTestObject(‘Reset Wishlist/Page_Your store. Wishlist/a_HTC One M8 Android L 5.0 Lol’), ‘HTC One M8 Android L 5.0 Lollipop’)

can anyone help me out how can i map with this methods of test case 1 into the test case-2 , so i can call test case 1 in test case 2

Nope, this is not working for me
I initialize my global variable like this:


Change its value in TC 1 and use it in TC 2 but its still blank

That’s how they work. Your initial value is re-assigned at the start of each test case. If you think about it, how else could it work? Re-assign the value you used last week?

I handle this by reading my globals from an external file. If I need to share the same value between tests, I use callTestCase - usually that means I don’t need a global since a Test Case can return a value (which might be a Map of values).

Thanks a lot for the response, I could make my TC work.