namshree
Katalon Apprentice
04/12/2018

How to use number variable in test case

Hello,
I need to use integer variable in test case. How should I call?

I declared local variable 'acc_num' with default value type 'Number' and default value as '10000'.

I used this for calling variable->
Mobile.setText(findTestObject('account_number'), acc_num, 0)

But this is displaying error->
Test Cases/JoinHaggle FAILED because (of) groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.setText() is applicable for argument types: (java.lang.String, java.lang.Integer, java.lang.Integer) values: [account_number, 10000, 1]
Possible solutions: setText(com.kms.katalon.core.testobject.TestObject, java.lang.String, int), setText(com.kms.katalon.core.testobject.TestObject, java.lang.String, int, com.kms.katalon.core.model.FailureHandling), getText(com.kms.katalon.core.testobject.TestObject, int), getText(com.kms.katalon.core.testobject.TestObject, int, com.kms.katalon.core.model.FailureHandling)

Test Cases/JoinHaggle.run:39



Upvote
Quote

Comments

  • duyluong
    Katalon Ambassador
    04/16/2018
    Please use String.valueOf(<your_variable>)
    Best Answer
    Upvote
    Quote
  • Mate Mrse
    Katalon Expert
    04/12/2018
    setText takes expects a string as third parameter. 
    Try this:
    Mobile.setText(findTestObject('account_number'), toString(acc_num), 0)
    Upvote
    Quote
  • namshree
    Katalon Apprentice
    04/12/2018
    I want integer. Then what do I need to use?
    Upvote
    Quote
  • Mate Mrse
    Katalon Expert
    04/12/2018
    Did you try it?

    Mobile.setText(), as the name suggests, sets some text to your element (presumably some input field). Groovy's toString() will convert your integer to string, but I think it will send '10000' to your input field anyway. Try and see what happens.
    Upvote
    Quote
  • namshree
    Katalon Apprentice
    04/13/2018
    It is giving error.
    Can you tell any other method to set numbers in text field (other than setText)?
    Upvote
    Quote
  • Mate Mrse
    Katalon Expert
    04/13/2018
    Upvote
    Quote
  • namshree
    Katalon Apprentice
    04/16/2018
    I will elaborate again what I need to do exactly.
    I want to increment account number with each iteration of for loop.

    Something like this->

    int acc_no = 1000 // This is local variable
    for (def i = 1; i < 10; i++) {
    // set acc_no in text field account_number
    // increment acc_no by 100 with each iteration of loop
    }

    How can I do this?

    Upvote
    Quote
  • namshree
    Katalon Apprentice
    04/16/2018
    Thank you.. It worked..
    Upvote
    Quote
  • Vasudha Vanol
    Katalon Apprentice
    08/16/2018
    duyluong said:
    Please use String.valueOf(<your_variable>)
    It works for me.....
    Upvote
    Quote
Sign In or Register to comment.
Not the answer you're looking for? Consider subscribing to Business support.