Forum Discussion

ian_carter's avatar
ian_carter
New Contributor
11 years ago

Verifying objects randomly results in object not found

I have configured a script for a site where it launches FireFox | Logs into the site | Clicks a link and verifies all checkboxes exist on the page, then moves onto the next link, and so on.



Sometimes the script will complete without any errors, but sometimes the script will complete with errors randomly that it cannot find certain objects.  Every time the script is ran and fails, it's always at a different location where the object can't be loaded.  So I can't just add a wait to one object because I never know where it'll fail next.



The object IDs exist on the page, nothing has changed.  



For my VerifyField function, I've tried to add a Refresh() so that it will refresh before verifying the object exists.  However, intermittently, I'm still seeing the errors at random places.  



I don't know if a Wait function is going to help as there are a ton of VerifyField that take place in this one script.  



I'm still doing research on this but if anyone has any input, it'd be appreciated.  



Thanks, 
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    Rather than putting a wait on one of the objects, I might try a delay after the refresh but before you check any of the objects.  Perhaps they aren't all loading by the time your test gets around to checking.
  • ian_carter's avatar
    ian_carter
    New Contributor
    Let your suggestion marinate over the weekend, but I'm still seeing the random objects that aren't verified.  



    For now, I took out the delay because it was causing more errors than the original script.  It also caused random errors on my local server which always passed previously.  



    Are there any other functions that can be used to get this test more consistent?  
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    Could we see your VerifyField function?  Maybe that will help.
  • matt_1's avatar
    matt_1
    Occasional Contributor
    We call a simple function that waits for the page to load for any post backs that occur within our application, and I've had to add a 1 second delay to that function to deal with similar issues you are describing.



    We have over 5000 test cases and from time to time I see issues with Test Execute moving too fast and not recognizing an object on the page (even with the post back function), so I periodically add in waits for those troublesome objects as they occur.





    Our function that handles post backs



    Sub subPageSync()

     Do While Aliases.pageSchooltool.Busy

        Aliases.pageSchooltool.Wait()

     Loop 

     Delay (1000)

    End Sub
  • ian_carter's avatar
    ian_carter
    New Contributor
    Thank you for the suggestions.  Last few days I have been modifying the function to see if I could get around the random errors but they're still happening.  Here is the VerifyField function:




    function VerifyField(Field)




      //Refreshes page for each object


      g_Shortcut.pageWebpage1.Refresh();


      


      //Waits for objects on page before script continues


      g_Shortcut.pageWebpage1.WaitItem(VerifyField, 100);


      


      //g_Shortcut.RefreshMappingInfo();


      /*if (Field == "StopMD" && g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Exists)


      {


        g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Keys("[Enter]");


        Log.Message("The " + Field + " field loaded properly.");


      }


      else if (Field == "StartMD" && g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Exists)


      {


        g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Keys("[Enter]");


        Log.Message("The " + Field + " field loaded properly.");


      }


      else if (Field == "DomainCount" || Field == "UserCount" || Field == "GatewayCount" || Field == "ListCount" || Field == "MessageCount")


      {


        var Number;


        


        Number = g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).textContent;


        


        if (Number >= '0')


          Log.Message("The " + Field + " is " + Number + ".");


        else


          Log.Error("The " + Field + " field did not display a correct value.");      


      }*/


      //else if (g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Exists)


      if (g_Shortcut.pageWebpage1.document.frames.Frame("rightpane").document.all.Item(Field).Exists)


        Log.Message("The " + Field + " field loaded properly.");


      else


        Log.Error("The " + Field + " field did not load properly"); 


    }

  • ian_carter's avatar
    ian_carter
    New Contributor
    Hello everyone,



    I'd just like to see if anyone has had a chance to look at the script I'm using to verify fields.  

    I'm still having this issue intermittently.  I've tried the suggestions in this thread:



    Placing a delay after a refresh

    Placing a refresh after a delay

    Adding a 1 second delay



    Any help would be appreciated.



    Thanks!