Hi,
I have a input field with sys.Process("some property").SwingObject("some property").SwingObject("some property").SwingObject("input field name","",0) in the Test Project.
I need to access the last SwingObject in the above path.
I first want to find all the children of the sys.Process including all the child/grand child swing objects and then use index to perform operations on those objects.
p = Sys.Process("xyz");
let pp = p.FindAllChildren(" "," ",7); //tried adding javafullclassname property but didn't work
if (pp.length > 0){
for (i = 0; i < pp.length; i++){
Log.Message(pp[i].FullName);
pp[i].click();
pp[i].keys(u);
}
Hi,
> .FindAllChildren(" "," ",7)
The above line of code says: "Find all children up to the depth of 7 that have property with the name <one space> and the value of this property equals to <one space>".
I bet no such object exists in your application.
If you like to get all children up to level 7, then provide a property that exists for any object and indicate that it may have any value. E.g.: .FindAllChildren("name","*",7)
If you like to get just input fields, the code might be like this: .FindAllChildren("input field name","*",7)
Thanks Alex!
Hi @TestQA1 , I see that you replied straight to the email notification, this way your reply won't be posted to the community.
Let me quote it for this time, please reply inside the community in the future, thank you!
Here's your reply:
>>
Hi,
@sonya_m :
Sonya, thank you for reposting the reply.
@TestQA1 :
> What I'm trying to do is to get all children
And ?
Hi Alex,
The swing desktop app has a login page with a login dialog on it. I have been trying to first get all the child/grand child objects on the dialog and then want to perform operation on those grand child objects using index.
Javafullclassname property is there for username and password fields. But, I am not able to fetch these two objects.
Thank you.
Hi,
> I am not able to fetch these two objects.
Any more details? Your code? Error message? What line of code throws the error? Screenshot of Object Browser with one or both objects that you'd like to find? Anything else that can help others to understand what you have tried and what exactly does not work for you?
Object Explorer Hierarchy:
Sys.Process("abc").SwingObject1(some property,value).SwingObject2(some property,value)
Now SwingObject2 has two childs, SwingObject2.1(some property,value) and SwingObject2.2(some property,value)
I want to fetch all childs of SwingObject2.1 (lets say it has 5 direct childs and I want to get SwingObject2.1.2) above through iteration or something.
l = Sys.Process("abc");
ll = l.SwingObject2("some ClassName", "value",index , WndIndex);
lm = ll.FindAllChildren("JavaFullClassName","value of the class of the SwingObject2.1.2 ",10);
if(lm.length>0){
Log.Message("length exist");
Log.Message(lm.FullName);
}
}
else {
Log.Message("else")
}
Is this the right way to iterate through swing objects? And I don't know how to find indexes in Object Tree, I'm sorry I am new to Test Complete.
Thanks
I want to add that it's not throwing error, but instead of showing FullName it showing empty list.
Hi,
> instead of showing FullName it showing empty list.
.FindAllChildren() returns an array of found objects.
In your code (lm.FullName) you are trying to get the value of the .FullName property of the array. As the array does not have FullName property an empty value is returned.
Documentation for .FindAllChildren() method provides an example with the iteration through the resulting array. Check it and I hope that it will help.
As an example, modification of your code (JavaScript):
if(lm.length>0){
Log.Message("length exist");
for (let i = 0; i < lm.length; i++) // iterate through the array
Log.Message(lm[i].FullName);
}
Subject | Author | Latest Post |
---|---|---|