How to enter two integers using SetText method
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excellent! Thanks again for your help!
