Please post your Web Driver questions in official Web Driver forum

Tuesday, March 23, 2010

VB Script and Square Brackets '[]'

I had tough time working with vb script and square brackets '[]'. Looks like square bracket has special meaning when it comes to regular expression in vb script.
I was trying to write DP for check box collection on page as -

******************************************************************************
Browser("name:=.*").Page("title:=.*").WebCheckBox("name:=publishedSectionId[0]").Set "ON"
******************************************************************************

Execution of this line resulted in following error -

******************************************************************************
"Cannot identify the object "[ WebCheckBox ]" (of class WebCheckBox). Verify that this object's properties match an object currently displayed in your application."
******************************************************************************

I wonder if this error makes any sense, any ways problem is with square brackets in name property which is -

****************************
name:=publishedSectionId[0]
****************************

To correct this I provided backslash before square bracket -

****************************
name:=publishedSectionId\[0\]
****************************

and got through. :-)
Fork me on GitHub