VBScript 常用函数总结
2019-10-26 18:03:03
供稿:网友
 
				下面是我总结的VBScript中常用的函数及其用法。 
  1,GetROProperty 
  说明:You use the GetROProperty method to retrieve the current value of a test object property from a run-time object in your application. 
  一般来说,所有的对象都可以使用此方法得到运行时对象的实际值。 
  语法:object.GetROProperty (Property, [PropertyData]) 
  如 ButtonName=Browser("QA Home Page")。Page("QA Home Page")。WebButton("Submit")。GetTOProperty("Name") 
  2,WaitProperty 
  说明:Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step. 
  此方法可以解决由于等待系统进行处理某些操作或网络原因引起的测试对象同步问题。 
  语法:object.WaitProperty (PropertyName, PropertyValue, [TimeOut]) 
  如 
  Window("Test")。Static("Status:")。WaitProperty "text", "Ready", 30000 
  3,Instr 
  Returns the position of the first occurrence of one string within another. 
  可以得到一个字符串在另外一个字符串中首次出现的位置。 
  语法: InStr([start, ]string1, string2[, compare]) 
  4,Split 
  Returns a zero-based, one-dimensional array containing a specified number of substrings. 
  此函数可以把原来用某个特殊字符串连接起来的字符串分割开,得到一个一维的数组。 
  5,UBound 
  Returns the largest available subscript for the indicated dimension of an array. 
  得到某个维度的最大值。 
  6,Trim 
  Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim)。 
  如果需要删除字符串左边的所有空格,那么可以使用LTrim 函数;如果需要删除字符串右边的所有空格,那么可以使用RTrim 函数。如果需要删除字符串左边和右边的所有空格,那么可以使用Trim 函数。 
  7,Ucase 
  Returns a string that has been converted to uppercase. 
  此函数可以把所有的字符都转换成相应的大写。 
  8,LCase 
  Returns a string that has been converted to lowercase. 
  此函数可以把所有的字符都转换成相应的小写。 
  9,Cstr 
  Returns an expression that has been converted to a Variant of subtype String. 
  由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成String类型。 
  10,CInt 
  Returns an expression that has been converted to a Variant of subtype Integer. 
  由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成Integer类型。