简体   繁体   中英

typeError in calling user defined test library function ( with arguments ) in robot framework

I have user defined function saveLogin in test library implemented as follows.

def saveLogin(userId,serialNo):
    conn = sqlite3.connect('new.db')
    conn.execute("INSERT INTO login VALUES(?,?)",userId,serialNo)
    conn.commit()

When i try to call this function . In test case sessionTest,

sessionTest
    saveLogin    ${CRE_USER_ID}    1

Getting following error :

sessionTest
          | FAIL |
**TypeError: function takes at most 2 arguments (3 given).**

When i pass only 1 argument

sessionTest
    saveLogin    ${CRE_USER_ID}

sessionTest
   | FAIL |
**Keyword 'getSequence.Save Login' expected 2 arguments, got 1.**

Not able to figure out the reason for this error .

Problem was the argument to the sqlite function execute . execute function expects at most 2 arguments . Modified function saveLogin to pass correct arguments to execute function. Earlier i was passing 3 arguments , hence the error was coming.

def saveLogin(userId,serialNo):
    conn = sqlite3.connect('new.db')
    values = ( userId,serialNo)
    conn.execute("INSERT INTO login VALUES(?,?)",values)
    conn.commit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM