Forum Discussion
5 Replies
- Tom_EOccasional ContributorHave you considered passing in the name of the server as a parameter?
- OlgaBOccasional Contributor
Passing where? I don’t use all these names in my tests. What is happening, I think, my tests were recorded with some objects. TC mapped them and used them in my test. For example TC found and mapped the following object
“Sys.Process("myappl").SWTObject("Shell", "Myapplication - user@server2008 - QA_SQL2008_65:1433").SWTObject("Composite", "", 5)”.
Then I pointed my application to another server and the object became
“Sys.Process("myappl").SWTObject("Shell", "Myapplication - user@AnotherServer2008 - QA_SQL2008_65:1433").SWTObject("Composite", "", 5)”
TC find new object and mapped it differently. In first case it is Shell1, in second case it is Shell60.
- witteOccasional ContributorYou can use wildcards * in the name (Shell*).
Or you don't define the object by his name. Use the Find or FindChild Method and search for Property/Value which is available of this object.
Hope it helps. - witteOccasional ContributorIn addition to my last post:
=================
Object should be found if you use the wildcards as in following example:
=> Sys.Process("myappl").SWTObject("Shell*",
"Myapplication - *").SWTObject("Composite", "", 5)
But I'd like to give you a notice for better scripting. It's not a patch on you!
1) you shouldn't use capture and replay without changing some code. This is because names or indexes and so on may change during test and test script has to be changed evry time. This is not effective :-)
2) Use variable and check if object exists, then further on with next steps. That makes more stable the testrun.
=> Example:
var appName = "myappl";
var application = Sys.Process(appName);
//use any unique property or more if neccessary
if(application["FindChild"]("ObjectIdentifier", "Myapplication - *", 10, true)["Exists"]){
myApp = application["FindChild"]("ObjectIdentifier", "Myapplication - *", 10,false);
//if you need the index too, then define array with params and values
myApp["FindChild"]("Name", "Composite", 5, true);
} - OlgaBOccasional Contributor
Thanks SW. It works now :)
. When I saw your suggestion to use wildcard I started to imagine how many
objects I need to modify. But actually I had to change a couple.