Forum Discussion

melqaisi's avatar
melqaisi
New Contributor
15 years ago

System can't get the value in the running mode.. but in debugging it works perfectly.

Hi everybody,



I am trying to solve a problem in my test script with no hope, so I am asking for the help here : 



The problem is as the following : 



I have a function and this function tests some elements of the tree... and then i make some validation of some text in the tree items






         if (tree["WPFObject"]("TreeViewItem", "", i)["WPFObject"]("TreeViewItem", "", x)["WPFObject"]("TreeViewItem", "", z)["WPFObject"]("Grid", "", 1)["WPFObject"]("GridViewRowPresenter", "", 1)["WPFObject"]("ContentPresenter", "", 7)["WPFObject"]("TextBlock", SLDdesc, 1)["Text"]== SLDdesc){   //Verify SLD description// TODO 2 -cVerification Of SLD Description : SLD description                                                                                                                                                                                                                   

                                      Log["Message"]("SLD Description saved correctly");  

                                              if (tree["WPFObject"]("TreeViewItem", "", i)["WPFObject"]("TreeViewItem", "", x)["WPFObject"]("TreeViewItem", "", z)["WPFObject"]("Grid", "", 1)["WPFObject"]("GridViewRowPresenter", "", 1)["WPFObject"]("ContentPresenter", "", 6)["WPFObject"]("TextBlock", SLDreference, 1)["Text"] == SLDreference)

                                                     Log["Message"]("SLD Reference saved correctly");  



when i run this function only it works perfectly.... and when i run it integrated with some  the other functions the log messages doesn't appear to be reachable. when i make break points on the if statements it also work.



I also tried to make this  to make the validation using the "Olevalue " proberty, sometimes it works and sometimes it tells me that the function return object.



Can you help me please?



Thanks,



Mohammed.

4 Replies

  • Hi Mohammed,


    Please clarify the problem. Do you worry that the "SLD Description saved correctly" and "SLD Reference saved correctly" messages do not appear in the test log or that some errors occur during the test run?


    The messages may not be posted to the test log if the verification does not pass. To check this, I recommend that you add the else statement to the test. For example:




    if (tree["WPFObject"]("TreeViewItem", "", i)["WPFObject"]("TreeViewItem", "", x)["WPFObject"]("TreeViewItem", "", z)["WPFObject"]("Grid", "", 1)["WPFObject"]("GridViewRowPresenter", "", 1)["WPFObject"]("ContentPresenter", "", 6)["WPFObject"]("TextBlock", SLDreference, 1)["Text"] == SLDreference)                                                    

      Log["Message"]("SLD Reference saved correctly"); 

    else

      Log["Warning"]("SLD Reference saved incorrectly"); 


    If errors occur during the test run, please specify the text of the error messages.

  • melqaisi's avatar
    melqaisi
    New Contributor

    Thanks alot Margaret for your
    replying,



    My problem is, when I execute the code without any breakpoints, the ["Text"] property is returned as an object and doesn't return text, where if i make a break points, on the if statement it returns the value of the text that i want and compare the right values.


    tree["WPFObject"]("TreeViewItem", "", i)["WPFObject"]("TreeViewItem", "", x)["WPFObject"]("TreeViewItem", "", z)["WPFObject"]("Grid", "", 1)["WPFObject"]("GridViewRowPresenter", "", 1)["WPFObject"]("ContentPresenter", "", 6)["WPFObject"]("TextBlock", SLDreference, 1)["Text"]



    In the test log there is no errors, because at the condition it is going to see it as an object -i mean the property text- and it compares it with a string and this result is false always



    The same exact problem was happening when i use the Olevalue property and didn't know what's wrong!



    is there anything wrong i am doing? 



    Thanks,



    Mohammed.
  • Hi Mohammed,


    Could you please send us your entire script? And please specify what TestComplete version are you using?

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    It sounds like there is a timing problem in your automation where the test is running faster than the application.  So, the Text object gets returned blank because the automation is attempting to evaluate it before it has completely loaded.



    As simply a diagnostic, try adding a call to aqUtils.Delay(5000) right before your line of code and see if that helps.  If so, you might want to look into using something like WaitAliasChild or something to wait for an object to resolve before trying to retrieve the text.