Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
4 years ago

Accessing SwingObjects using FindAllChildren

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);

}

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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)

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      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, 

       
      I'm sorry I should have entered property name and value in FindAllChildren, just left it blank for the post, in actual I put the property and the value in real code. What I'm trying to do is to get all children on the user credentials dialog and then extract username and password based on index. Javafullclassname property is available for username and password field and for the dialog that contains those field has AWT properties.
      <<
       
       
      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        sonya_m :

        Sonya, thank you for reposting the reply.

         

        TestQA1 :

        What I'm trying to do is to get all children

        And ?