Execute Javascript from QuickTest Pro
Tuesday, May 20th, 2008Despite persistent the rumors to the contrary, you really can execute Javascript from QTP, and not just using Web Extensibility. Here is a simple function that will run some javascript in IE and return the result.
-
Public Function evalJS(oBrowser, sJavaScript)
-
Set JSEntry = oBrowser.object.document.documentelement.parentnode.parentwindow
-
On Error Resume Next
-
evalJS = JSEntry.eval(sJavaScript)
-
On Error Goto 0
-
End Function
-
-
Set oBrowser = Browser("version:=inter.*")
-
evalJS oBrowser, "alert('Hello, world');"

