1
votes

Is there a way to run our automation scripts in UFT using Headless browsers, similar to what we do using selenium?

The scripts that i am running now consumes up lot of time and are very slow.

I am relatively new to UFT and did some research on the web w.r.t headless testing using UFT but couldn't find any.

Any pointers or suggestions shall be appreciated.

2

2 Answers

0
votes

Are you looking similar to below code?

Public Function GetAllLinksInthePage()
    Dim oIE
    Set oIE = CreateObject("InternetExplorer.Application")
    oIE.Visible = False
    oIE.Navigate2 "http://newtours.demoaut.com/"
    Wait 4
    Set oIEDocument = oIE.Document
    Set oLinkCollection = oIEDocument.getElementsByTagName("A")
    iLinkCount = oLinkCollection.Length
    If iLinkCount > 0 Then
        For iCount = 0 To iLinkCount - 1
            Print oLinkCollection(iCount).Text
        Next
    End If  
    Set oIE = Nothing
End Function
0
votes

If you application offers rich set of API in form REST or SOA, you can use XMLHTTP object. It is independent of QTP/UFT. It's pure VBSscript and can be used anywhere. The sad part is that you must do lot of coding from scratch, but it is quite easy.

dim xmlhttp, fso, f1, serverURL
Set xmlhttp = Createobject("Microsoft.XMLHTTP")
serverURL = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Atlanta+GA+USA&destinations=Dallas+TX+USA&units=imperial&sensor=false"
xmlhttp.Open "POST", serverURL, false
xmlhttp.Send
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("D:\Sample VB Scripts\testfile.xml", True)
f1.write xmlhttp.ResponseText
f1.close

Sample XMLHTTP code