Forum Discussion

JeanL's avatar
JeanL
Contributor
16 years ago

Item.Exists => Object does not support this property or method

Hello,



how come this piece of code isn't working?



Dim page

Dim button



Set page = GetPage("http://www.my_example.com")

Set button = page.Form("aspnetForm").Item("btn_cancel")

If button.Exists Then button.Click

page.Wait()



When execution of the script reaches to If-condition TestComplete 8 gives VBScript runtime-error and says "Object does not support this property or method". However, Support portals article about Item Method (Web Objects) states that "If the specified element does not exist, the method returns a stub
object. To determine whether the method returns an existing element,
check the Exists property of the returned object". But in this case Exists property causes error.



In above code example the button.Click works without the If-statement.

1 Reply


  • Hi Jussi,





    You need to use the WaitItem method instead of Item:







    Set button = page.Form("aspnetForm").WaitItem("btn_cancel", 5000)







    We will correct the corresponding Help article.