Skip to content

Instantly share code, notes, and snippets.

@aaira-a
Created April 17, 2014 09:53
Show Gist options
  • Save aaira-a/10969876 to your computer and use it in GitHub Desktop.
Save aaira-a/10969876 to your computer and use it in GitHub Desktop.
Robot Framework variable file in Python, accessed using extended syntax from test case file.
class database(object):
def __init__(self, env):
if env == 'test':
self.name = str('test mysql 1')
self.host = str('1.1.1.1')
self.port = str('11')
self.login = str('testlogin')
self.password = str('testpass')
elif env == 'beta':
self.name = str('beta mssql 2')
self.host = str('2.2.2.2')
self.port = str('22')
self.login = str('betalogin')
self.password = str('betapass')
elif env == 'prod':
self.name = str('prod aws 3')
self.host = str('3.3.3.3')
self.port = str('33')
self.login = str('prodlogin')
self.password = str('prodpass')
*** Setting ***
Variables connectionstrings.py
*** Variables ***
${env} test
${DB} ${database('${env}')}
*** Test Case ***
My Test Case 1
Sleep 1s
Log To Console ${DB.name}
Log To Console ${DB.host}
Log To Console ${DB.port}
Log To Console ${DB.login}
Log To Console ${DB.password}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment