Forum Discussion

mrouse's avatar
mrouse
Contributor
13 years ago

RunTime error Object expected?

Hello all,



I am getting a RunTime error message "Object expected" (see attached) when I run my TestComplete script.  It occures when the test gets to the If statement below



Appswitchertextis =  Aliases.iexplore.pageEmds.panelFullwindow.panelMaincontent.panelMainheader.textnodeAppswitchertext3.outertext;

 

  If( !Appswitchertextis == "Schedule" )

   {

 

     Aliases.iexplore.pageEmds.panelFullwindow.panelMaincontent.panelMainheader.textnodeAppswitchertext.Click(); //.Click(147, 9)

     Aliases.iexplore.pageEmds.panelFullwindow.panelMaincontent.textnodeAppswitchw.textnodeSchedule.Click(); //Click(48, 11)

    

   }



The Appswitchertextis var does contain the "Schedule" string which is expected. (checked just before the if statement).



I don't know if the error occurs due to the If statement line or the statements in the If statement's body.  All I know is it occurs when I F10 past the 1st line of the If statement line.



I looked through the fourm but couldn't find a lot on runtime errors. 



Thanks for any help.



Mike


4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Your problem is in this line



     If( !Appswitchertextis == "Schedule" )




    You want to test if it is not equal to "Schedule".  A better way of writing this is



     If (Appswitchertextis != "Schedule" )
  • Robert,



    Thanks for the reply. 



    Also, I wasn't aware of the case sensitivity for the properity.  Ss far as the rest of the line (first part) can I just cut and paste the MappedName out of the Object Spy and assume the case is right?  The reason I ask is when I look at the MappedName in the Object Spy and compare it to the Object Browser the case is different.



    Thanks,



    Mike
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Mapped name of an object is not the same as the actual object name itself.  But outerText is not an object, it's a property which cannot be "mapped".



    In any case, let me know if these couple of corrections fix things.
  • Hi Robert,



    Your suggestions did help to "Fix" the problem but didn't get me all the way there.  But I did get the Runtime error corrected and I hate to write this down because it was so stupid and simple, but hopefully for the benefit of others...



    The reason for the RunTime error was because I misspelled the if in the if statement with an  upper case "I" instead of "if".



    Thanks,



    Mike