后接一个URL地址,例如“http://www.itestware.com”,即可使用SAFFRON框架中的BrowseTo函数导航到指定的
URL地址,如下脚本所示:
'BrowseTo(url)
BrowseTo "http://www.itestware.com"
4、、SAFFRON框架代码剖析框架代码剖析
为了深入了解SAFFRON,以及框架的使用方法,下面我们将分别介绍SAFFRON中的主要函数,对SAFFRON代
码进行深入剖析。
4.1 导航到指定导航到指定URL
SAFFRON使用名为BrowseTo函数来负责导航到指定的URL,如果浏览器尚未启动,则先调用函数Launch来打
开浏览器。BrowseTo函数的定义如下所示:
Public Function BrowseTo (url)
thirdlevel = ""
Report micPass, "Navigate to URL", "Navigating to URL: " & Quote(url)
If initialized Then
Execute GenerateDescription("Browser") & "Navigate " & Quote(url)
Else
Launch "website", url
End If
Reporter.Filter = rfDisableAll
End Function
在脚本中,会判断是否初始化了浏览器,如果有则执行导航动作,导航到指定的URL。导航动作是执行这行脚本
来完成的:
Execute GenerateDescription("Browser") & "Navigate " & Quote(url)
Execute是一个用于执行指定VBScript脚本语句的函数,GenerateDescription函数的定义如下所示:
' Generates a generic description based up on the "level" viarable
' levelstr - will be one of the values that is in the level array
' returns - string representative of the object hierarchy
Public Function GenerateDescription (levelstr)
l = IndexOf(level, levelstr)
If l >=0 Then
fdesc = level(0) & "(" & Quote(desc(0)) & ")."
If l >= 1 Then
fdesc = fdesc + level(1) & "(" & Quote(desc(1)) & ")."
If 2 >= l Then
If thirdlevel <> "" Then
fdesc = fdesc + level(2) & "(" & Quote(desc(2)) & "," & Quote("name:=" & thirdlevel) & ")."
End If
End If
End If
End If
GenerateDescription = fdesc
End Function
4.2 返回测试对象的描述返回测试对象的描述
评论0
最新资源