Ask a Question

FTP with dynamic Port values

Occasional Contributor

FTP with dynamic Port values

Hi community,


I have a script that loads dynamic values in TestSuite properties. It looks like this:


import com.thoughtworks.xstream.mapper.Mapper"Initialize TestSuite for ProPlannerVehicle")

def testSuiteName ="testSuiteName: " + testSuiteName)

def env_extracted = testRunner.testCase.testSuite.project.getPropertyValue("arg_environment")
def env_extracted_from_name = testSuiteName.substring(10, testSuiteName.length() )"env extracted: " + env_extracted)"env extracted from name: " + env_extracted_from_name)

if(env_extracted == null) {
if(env_extracted_from_name == 'DEFAULT') {
env_extracted = testRunner.testCase.testSuite.getPropertyValue("defaultEnvironment")
} else {
env_extracted = env_extracted_from_name
}"env computed is: " + env_extracted)

//create null Strings for tmpVariables
def host = ''
def env = ''
def port = ''

switch (env_extracted){
case 'TT':
host = ''
port = '26'
env = 'TT'
case 'CI':
host = ''
port = '26'
env = 'CI'
case 'DV':
host = ''
port = '22'
env = 'DV'
case 'QA':
host = ''
port = '24'
env = 'QA'
case 'PP':
host = ''
port = '21'
env = 'PP'
case 'TR':
host = ''
port = '23'
env = 'TR'
log.error("ERROR: Target environment '" + env_extracted + "' not handled.")"ERROR: Target environment '" + env_extracted + "' not handled.")
}"Host found: '" + host + "'")"Environment found: '" + env + "'")

testRunner.testCase.testSuite.setPropertyValue( "tmpPort", port)

testRunner.testCase.testSuite.setPropertyValue( "tmpHost", host)
testRunner.testCase.testSuite.setPropertyValue( "tmpEnvironment", env)
testRunner.testCase.testSuite.setPropertyValue( "tmpTestSuiteName", testSuiteName)
testRunner.testCase.testSuite.setPropertyValue( "tmpId", "ESB_SANITY_" + env)

Then I want to use the 'tmpPort' value in my ftp step. It must be an int value but I get a String value if i use ${#TestSuite#ftpPort}. Does somebody have a solution for this?

Super Contributor

Sorry, I'm on an older version of Ready API that doesn't have the FTP test step, are you saying that when you go into your FTP Test Step and in the "Port" box you type "${#TestSuite#ftpPort}" Ready API immediately reports an error that it is not an integer, thus won't let you configure the FTP Test Step?


If so I would suggest that you put a Property Transfer test step in just before your FTP step and you can use this to copy in the value from your test suite property into the FTP test step at runtime.

Occasional Contributor

No it just doesn't want to do the ftp. But I found a workaround :


I added this script and it works:


// Get the test step objects
def tsFTP1 = testRunner.testCase.getTestStepByName("03_FTP_file1")
def tsFTP2 = testRunner.testCase.getTestStepByName("04_FTP_file2")
def tsFTP3 = testRunner.testCase.getTestStepByName("05_FTP_file3")
def tsFTP4 = testRunner.testCase.getTestStepByName("06_FTP_file4")
def tsFTP5 = testRunner.testCase.getTestStepByName("07_FTP_file5")

//Get the port number
def tmpFtpPort = context.expand( '${#TestSuite#tmpFtpPort}' )

// Set the ports

Thanks for posting your work around of doing the property transfer via a Groovy script, hopefully that will help others.


Though I must admit this feels like a Ready API bug. Rather unhelpfully the FTP Test Step documentation states "Some fields of the editor allow you to use Property Expansions." (my emphasis), but doesn't say which ones!


I would of assumed that if you weren't able to use a property expansion then it would only allow you to enter an integer value via the test step editor. It may be worth raising this as a SmartBear support case:


Get the official answer on if you should be able to use a property expansion.

Showing results for 
Search instead for 
Did you mean: