vendredi 11 septembre 2015

Robot framework: looping through kwargs

I have need to take a list of keyword arguments in robot and convert them to a string of the form key=value if the keyword is in a certain list and set key=value if not. In python, it looks like this:

keywords=#list of keywords

def convert(**kwargs):
    s = ''
    for k,v in kwargs.iteritems():
        if k in keywords:
            s = s + '-%s=%s ' % (k,v)
        else:
            s = s + '-set %s=%s ' % (k,v)
    return s

I know this could be simply written as a python keyword, but I'm trying to figure out if it's possible using Robot. I can iterate using :For ${arg} in ${kwargs}, but I'm not sure how it would work to retrieve the keys and values individually.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire