New Contributor
7 years ago

# How to enter two integers using SetText method

I am using Python scripting with TestComplete and I am hitting an issue.  I have a textbox in which I would like to enter two numeric values separated by a comma (i.e., 35, 50).  The closest method I can see that would work is SetText; however, I don't know how to enter two integers and have them show up as expected.

Here is my code thus far; if I input (a) into the last line, it returns 35.  If I input (b), then it returns 50.

def Test1():
a = 35
b = 50
Aliases.CoordinatesTextBox.SetText(a,b)

What do I need to do in order for 35,50 to be displayed?

• I'm not incredibly familiar with python so the syntax may be off.  Basically, you're going to need to concatenate those as strings... yes, I know they are integers, but SetText takes a string parameter so you're going to need to convert them to strings and then concatenate the strings.

It MIGHT look something like this

```def Test1():
a = 35
b = 50
coords = aqConvert.IntToStr(a) + ','+aqConvert.IntToStr(b)
Aliases.CoordinatesTextBox.SetText(coords)```
• I THINK it would simply be something like below... again, I'm not extremely familiar with Python so, from the little I've gleaned, this SHOULD work.

```def Test1(xCord, yCord):
coords = aqConvert.IntToStr(xCord) + ','+aqConvert.IntToStr(yCord)
Aliases.CoordinatesTextBox.SetText(coords)```

### 4 Replies

• tristaanogre
Esteemed Contributor

I'm not incredibly familiar with python so the syntax may be off.  Basically, you're going to need to concatenate those as strings... yes, I know they are integers, but SetText takes a string parameter so you're going to need to convert them to strings and then concatenate the strings.

It MIGHT look something like this

```def Test1():
a = 35
b = 50
coords = aqConvert.IntToStr(a) + ','+aqConvert.IntToStr(b)
Aliases.CoordinatesTextBox.SetText(coords)```
New Contributor

Robert - excellent!  That worked!

Taking this one step further, how would I setup Test1 so that I could pass in a and b as parameters ?  I would like to be able to write Test1(35,50) and have it enter 35,50 into the textbox field.

• tristaanogre
Esteemed Contributor

I THINK it would simply be something like below... again, I'm not extremely familiar with Python so, from the little I've gleaned, this SHOULD work.

```def Test1(xCord, yCord):
coords = aqConvert.IntToStr(xCord) + ','+aqConvert.IntToStr(yCord)
Aliases.CoordinatesTextBox.SetText(coords)```