Forum Discussion

TRoper's avatar
TRoper
Occasional Contributor
13 years ago

Flat vs. Tree for Object tree model.


Hi All,



Hi All,


I am trying to make the Name Mapping easier to use, I am
trying the “Flat” Object tree model. 
What I am attempting to do is clear a field in a window by dragging and
then setting the field to the correct value. 
This works in the “Tree” but not in the “Flat” mode of the Object tree
model.


In the “Flat”
model the statements in the test script are?:


Sub Test1


  Dim TASJDialog


  Dim
basicComboBoxEditor_BorderlessTextField


  TestedApps.TestedApp1.Run


  Set TASJDialog = Aliases.javaw.dialog0


  Set basicComboBoxEditor_BorderlessTextField
= TASJDialog.BasicComboBoxEditor_BorderlessTextField


  Call
basicComboBoxEditor_BorderlessTextField.Drag(319, 5, -319, 0)


  Call
basicComboBoxEditor_BorderlessTextField.Keys("This is the field to be set")


  TASJDialog.Button.ClickButton


End Sub


In the “Tree” model the statements in the test script are::


Sub Test1


  Dim projectChooser


  Dim
basicComboBoxEditor_BorderlessTextField


  TestedApps.TestedApp1.Run


  Set projectChooser = Aliases.javaw.dialog0.RootPane.null_layeredPane.null_contentPane.ProjectChooser


  Set
basicComboBoxEditor_BorderlessTextField =
projectChooser.Panel.Panel.ComboBox.BasicComboBoxEditor_BorderlessTextField


  Call
basicComboBoxEditor_BorderlessTextField.Drag(319, 5, -319, 0)


  Call
basicComboBoxEditor_BorderlessTextField.Keys("This is the field to be
set")


  projectChooser.Panel1.Button.ClickButton


End Sub


In the “Flat”
model, nothing is dragged.  The cursor
moves right to left just below the field I am trying to clear.  The original values were 319, 5 -319, 0.  I have changed them to everything from the
original values to 0,0 0,0 with no effect. 
Is there something I am overlooking?


Thanks for your
help.


Steve

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Steve,



    I'd recommend against using the Drag action in your scenario, because coordinates are unreliable. Try sending the Ctrl+A then Del keys instead. That is, replace:

    Call basicComboBoxEditor_BorderlessTextField.Drag(319, 5, -319, 0)

    Call basicComboBoxEditor_BorderlessTextField.Keys("This is the field to be set")
    with

    and see if it works.
  • TRoper's avatar
    TRoper
    Occasional Contributor
    Thanks Helen



    This does not work if the Option tree model is set to Flat.  It does work when the Option tree model is set to Tree.  Why is this?



    Unfortunately when the Object tree model is set to Tree, this makes the Name Mapping almost unusable to me.  On the application that I am trying to test, the Name Mapping tree can be  14 levels deep which makes writing scripts a nightmare.



    Thank you for your help.

    Steve
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Steve,



    It could be that basicComboBoxEditor_BorderlessTextField refers to different objects in the Flat and Tree models. To check if this is the case, insert the following line before the Drag operation in both tests:



    Then run the tests and see which exactly objects (the same or different) get highlighted.



    If the above is not the case, I'd like to ask you to open a Support Ticket and send your application under test and test project to our Support Team so they can investigate the issue more closely. They can sign an NDA if necessary.
  • TRoper's avatar
    TRoper
    Occasional Contributor
    Thanks Helen.  I appreciate your quick responses.  That statement generates a Microsoft VBScript error.



    I am having a lot more problems with the Tree vs Flat Object tree model.  All of the scripts I have tried fail with the Flat model.  If I create the exact same script using the Tree model, it works. I have been trying all week to get something figured out, to no avail.   I am afraid that if we go with TestComplete, that I will be forced to use the horrendously long Tree model.  For example, the first line is with the Flat model:



    Call Aliases.javaw.ChooseDomain.Domain.Keys(Project.Variables.Var11.Value("Domain"))



    This is the same line in the Tree model:



    Call Aliases.javaw.ChooseDomain.RootPane.null_layeredPane.null_contentPane.ProjectChooser.Panel.Panel.ComboBox.BasicComboBoxEditor_BorderlessTextField.Keys(Project.Variables.Login.Value("Domain"))



    This is the simple line.  There are lines that have twice the attributes.



    I just do not understand why the Flat model does not work and the Tree model does.



    Thanks

    Steve
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Steve,



    Unfortunately when the Object tree model is set to Tree, this makes the Name Mapping almost unusable to me. On the application that I am trying to test, the Name Mapping tree can be 14 levels deep which makes writing scripts a nightmare.
    You can actually shorten the recorded object names. You can do this by dragging child objects in the Aliases panel and dropping them up to grandparent, greatgrandparent, etc. objects. This way, you can reorganize Aliases to include only those objects that you are interested in and skip intermediate container objects. The Mapped Objects pane will still reflect the original object hierarchy, but Aliases can be shrunk to, say, 3 levels deep. Please see the following thread for details:

    How to shorten Aliases?





    That statement generates a Microsoft VBScript error.
    Could you please specify which error?

    Also, please try the following instead:



    Call Sys.HighlightObject(Aliases.javaw.dialog0.BasicComboBoxEditor_BorderlessTextField, 10, 255)



    I suspect that the issue with the Flat model is caused by non-reliable identification properties of the BasicComboBoxEditor_BorderlessTextField object, so that it matches another object at run time. This can happen in case of complex GUI applications with many objects, especially for Java applications and especially in the Flat model. The above line will highlight the identified object so you can see if it's the correct object or not.



    If a wrong object is highlighted when the Flat model is used, you need to modify the object's identification properties in Name Mapping so that they uniquely identify the needed object. For example, add additional unique properties, and so on.



    If the object is identified correctly in the Flat model, the issue might be more complex than it originally seems. For example, it might be specific to your tested application or environment. In this case, I recommend contacting our Support Team, because the forums aren't really suited for troubleshooting complex issues. The Support Team would be willing to take a look at your test project and your tested application, so please send them along with your original ticket (under an NDA if needed).