ScriptingContext.setValue syntax error in Jythlon
In the script below, the last line using "ScriptingContext.setValue" is returning an error in Details stating that:
" File "", line 7, in setTestFlowLogicVar
TypeError: setValue(): expected 3 args; got 2"
The api doc state the syntax is:
"boolean setValue(String variableName, String value)"
Where is this third arg coming from? The "Evaluate" scripting function does not return any error messages.
from com.parasoft.api import *
def setTestFlowLogicVar(input, context) :
rowCount = context.getValue("One time test prep (Delete failed user logins; get planned attempts)", "DeleteFailedLogins: updatedRows")
if (rowCount >= 0) :
# clear the FailedLoginAttempts DB flag indicating a successful reset if the SQL result does not return a null
success = ScriptingContext.setValue("bClearFailedLoginAttempts","false")
Comments
-
Hello,
I believe you need to use the context variable instead of the ScriptingContext class when calling the setValue method. Please try the following:
from com.parasoft.api import *
def setTestFlowLogicVar(input, context) :
rowCount = context.getValue("One time test prep (Delete failed user logins; get planned attempts)", "DeleteFailedLogins: updatedRows")
if (rowCount >= 0) :
# clear the FailedLoginAttempts DB flag indicating a successful reset if the SQL result does not return a null
success = context.setValue("bClearFailedLoginAttempts","false")Also, for your if statement, I believe rowCount is a String since that's the return value of the getValue method. I'm not sure if you're trying to do a condition statement for a String or int, but I just wanted to let you know.
Hope this helps.
0 -
Thank you, I had been using setVariable, which was deprecated to ScriptingContext.setValue according to the api doc. I'll give this a go.
0