Forum Discussion

chdittmer's avatar
chdittmer
Occasional Contributor
11 years ago

Project executes perfectly in TestComplete but fails in TestExecute

I have a project stress testing our entire package (Java). One part of the execution is clicking a Togglebutton. Completeing the test clicks this button around 4000 times perfectly in TestComplete without failure. If I run the same project on the same machine using TestExecute it fails the first time the button needs to be clicked. With a "annot find object error".



This is not the only Togglebutton that is clicked during the run but the only one failing the test. This is the only togglebutton that's state changes unpredictably so I use .ClickButton(false) whenever it's state could change to ensure it is in the untoggled state before I continue. 



I have tried to refresh the button's mapping dynamically during runtime in case it's unpredictable change in state is causing this but to no avail. Any suggestions?
  • I'm thinking that the button hasn't finished being created before TestExcute is clicking on it.  The easiest thing to do is to insert a delay before clicking on the button.  This will give more time for the button to exists.



    aqUtils.delay(1000)



    If this proves to be the case then, you can either keep the delay or use some code to trap the error and ignore it.  Then loop around to until the button exists so that it can be clicked on.



    I have had issues like this.  I use TestComplete on a different URL to the one I use TestExecute on.  The URL that TestExecute is for a slower server, so I have to have code to cope with that.
  • chdittmer's avatar
    chdittmer
    Occasional Contributor
    There is already a delay in place before the button is clicked.



    From what I can see the AWTAccessibleName changes every time the button is clicked. Could this have an effect on it's namemapping?



    If I manually click the button when expected while TestExecute is executing my script the tests continues for a while clicking the button without issue but not for very long before failing at that specific point again...
  • You should check the full name of the button over 2 runs to see if it changes.

    Just put a break point where the button is to be clicked.  Using the Object Spy in, TestComplete check the full name of the button. 

    Run the test again.  Again when the button is to be clicked in the test, use the Object Spy to check the value of the button.  If it is different to the first run then you would be better off using a Find method.
  • chdittmer's avatar
    chdittmer
    Occasional Contributor
    The Object spy shows the same value no matter when I check, the only thing I can see that changes is the AWTAccessibleName. As I say the tests dont fail when using TestComplete only when using TestExecute and I cant figure out what the difference is between the way the two executes tests?
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    We have seen the timing be different between TC and TE, so that doesn't surprise me.



    How does AWTAccessibleName change?  If it's a similar name every time, something like myname1 and myname2, then you could use a wild card in the name mapping so that myname* is always recognized.



    We have some cases where the field in question actually changes from being a text box to a combo box after some things load in the background so we had to check for both when we were trying to write in the field.  That could be showing up with a timing change.



    One other thing we just found was that there was an invisible-to-the-user object loading at the same level as a button so we ended up having to check for the object before we could click the button.  That's something else that's affected by timing.  
  • chdittmer's avatar
    chdittmer
    Occasional Contributor
    The AWTAccessbileName changes from "Start" to "Stop".



    I have tried changin the "Start" (As the togglebutton is currently mapped) to a wildcard in the name mapping but then it seems to not be able to find the object at all.



    I have been able to narrow down the failure to a very specific case. As I mentioned the button can change from Stop to Start if the conditions are right, the only time the test seems to fail is when this does not happen.



    So, in other words most of the time the Togglebutton will change from Stop (toggled) to Start (untoggeled), TE sees that it is in the state I want it to be and the test continues without an action taking place. When it does not change from that Stop to Start state the test fails when it tries to put it in the correct state by clicking the button.



    There are other parts of the test where this button is clicked (both Toggled and untoggled state) when it explicitly cannot have it's state changed without the button being clicked, during these times the script does not fail. 



    The function I use to click this button looks something like this:



    function ClickButton(state)

    {


        Aliasses.[namemapping].ToggleButton.ClickButton(state); }