Forum Discussion

riordanalex's avatar
riordanalex
Occasional Contributor
11 years ago

"Object does not support this property or method" JScript bug?

Using TestComplete 9.31 on a 32-bit Windows 7 machine.



The code:



Line 1: var toolbar = Aliases.epic.frmDesktop.NavTile.epicToolbar;

Line 2: toolbar.wButtonText(1, true); 



the variable toolbar is of type WinToolbar32, and it shows up properly in the Object Browser mapped correctly.



Line 2 is generating a JScript runtime error: "Object does not support this property or method"



Now, in real life, one would assign the result of a call to wButtonText to a variable, but should it really be generating a runtime error if we decide not to assign it to anything (was just playing around with some of the methods at this point)? Expected behavior would be for NOTHING to happen. This seems like a bug to me.

3 Replies

  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Isn't wButtonText a property, and not a method? What are those parameters you are passing to it? You are getting the message because you are trying to pass parameters to a property that doesn't support them. It's not a bug, your code is the bug.
  • riordanalex's avatar
    riordanalex
    Occasional Contributor
    Umm, if it was a bug with the parameters I was passing to the function, then it would generate a runtime error regardless if I did



    (1) var a = toolbar.wButtonText(1, true)



    vs



    (2) toolbar.wButtonText(1, true)



    Case (2) is causing a runtime error...



    http://support.smartbear.com/viewarticle/31036/ -- wButtonText takes two parameters... an Item (string or index) and a boolean.



    You are correct that it is a property, but I don't think it should matter how the property is used in the code, no? Just filing what I think is unexpected behavior.
  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Think about it a bit, what is your code doing in (2)? It's not doing anything! You are passing the property parameters, but not storing the return value. There is no point in running that line at all, unless you put the return value in a variable. Granted, I don't know why this is generating a runtime error, but it's something you would never do in real code anyways.