Ask a Question

capture/read the Table id from the header on the window screen

msap
Frequent Contributor

capture/read the Table id from the header on the window screen

capture/read the Table id from the header on the window screen

any suggestions

8 REPLIES 8
tristaanogre
Esteemed Contributor

Step 1: USe Object Spy on the window so you can get the properties

Step 2: Find the propery containing the header (probably WndCaption or something similar)

Step 3: Use aqString methods to parse out the Table ID (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/index.html)

 


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
msap
Frequent Contributor

objectspy captures the whole window - no luck with this.

 

tristaanogre
Esteemed Contributor

Exactly... because, in this case, the text in the title is not a separate object... it is a property of the full window.  So, ObjectSpy the Window and look for the desired text....  As I mentioned, it's probably something like "Caption" or "WndCaption" that is the property.

This is something that needs to be understood about applications, both Desktop and Web... sometimes what you see on screen is an object... sometimes it is the property of an object.  ObjectSpy tool is your BEST FRIEND in investigating your application under test to search out and figure out what is what... along with that, the Object Browser is the FULL view so that, once you Spy something, you can go to Object Browser and see if there is anything else that might be helpful (maybe there IS a child object that you need to look at which ObjectSpy is not finding).

This is a note to ALL new users of TestComplete: The root and core of TestComplete is in how it identifies objects and makes them "readable" by your tests.  The Object Browser and its extension Object Spy are your primary means of interacting with that.  And, by extension, NameMapping is how you then encapsulate those objects for consumption by your tests.  You would do well to spend MOST of your time in your test automation in these three areas... get these concepts and features "right", and everything works a LOT smoother.


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
msap
Frequent Contributor

Thanks Martin, I need few suggestions:

my order id = length changes from 6 to either 5 or 7  I am not sure how the last postion of the substring is implemented incase if its not constant.

 

Order #123456 - IPO

I need only the integer value start position(1) doesnot change but the end position(6) changes. means length of the id can be 6 to either 5 or 7

var w=OrderEntry2

 

var PropValue=aqObject.GetPropertyValue(w,"WndCaption");

Log.Message(PropValue);

var Str=PropValue;

var String1=aqString.SubString(Str,7,6)

Log.Message(aqString.SubString(Str,7,6));

 

 

tristaanogre
Esteemed Contributor

I would find the position of the hyphen (-) character, subtract your start position from that and use that result as your length... I think you may need to do a plus or minus one to that to get it to work right... and then use a Trim command to get rid of any spaces, if they are there... 


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
msap
Frequent Contributor

hi Martin

 

any suggestions how to use subtract from start position

 

var w=OrderEntry2
var PropValue=aqObject.GetPropertyValue(w,"WndCaption");
Log.Message(PropValue);
var Str=PropValue;


var Str3="-"
var Res=aqString.Find(Str,Str3)
Log.Message(Res)

// Res returns 14th positions


var Res6=aqString.SubString(Str,7,Res)
Log.Message(Res6)
var res7=aqString.GetLength(Res6)

tristaanogre
Esteemed Contributor

OK... first things first... go to https://www.w3schools.com/js/default.asp and take the basic tutorials on writing JavaScript code... this request this time is probably day one high-school programming course.  If you're going to be doing automated test development, I would STRONGLY recommend taking online tutorials or classes to get familiar with basic programming techniques.

 

That said... here's how I would write it

var captionString = OrderEntry2.WndCaption; //This returns the value of the property
var hyphenPosition = aqString.Find(captionString, "-"); //This finds the position of the hyphen
var tableIDLength = hyphenPosition - 7; //We know the starting position is 7 so simply subtract that from the hyphen start
var tableID = aqString.Trim(aqString.SubString(captionString, 7, tableIDLength)) //Use Trim and Substring to get the actual TableID
Log.Message(tableID)

 Code is tested and functional based upon a WndCaption in the format of Order #123456 - IPO


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
msap
Frequent Contributor

Thanks Martin. I was trying to see whther we have different functions for using subtract,  and operators are out of my mind.Sure will go through the course again thanks!

cancel
Showing results for 
Search instead for 
Did you mean: