Monday, March 22, 2010

QTP - Send test results as SMS to a mobile phone.

QTP - Send test results as SMS to a mobile phone.

When framework or test is getting executed (scheduled daily unattended) on production environments where test results are critical, it would be better to see the test results on your mobile immediately after the test completion, so that quick action can be taken if there are any anomalies.

There are different APIs available, I have used API provided by clickatell
You can register and test your code on this website.

Attaching sample code.

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oXMLHTTP = CreateObject("Microsoft.XmlHttp")
sUrl = "http://api.clickatell.com/http/sendmsg"
sAPI_ID = "xxxx"
sPassword = "xxxx"
sUsername = "xxxx"
sMobileNo = "xxxx"
sText = "Message from clickatell.com" ' Assign the SMS text message to this variable
sPostData = "api_id=" & sAPI_ID
sPostData = sPostData & "&user=" & sUsername
sPostData = sPostData & "&password=" & sPassword
sPostData = sPostData & "&to=" & sMobileNo
sPostData = sPostData & "&text=" & sText 
oXMLHTTP.Open "POST", sUrl, false
oXMLHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.Send sPostData
sResult = oXMLHTTP.responseText
Set oXMLHTTP = nothing
Wscript.Echo sResult
Set WshShell = nothing

After sending the message, you would receive following text as conformation message.






---

3 comments:

  1. But the Clickatell API for sms is chargable.Do you know any free API's like this.

    ReplyDelete
    Replies
    1. There will be no free api....It is not a open source, they need to pay for the service provider.

      Delete
  2. Hi I tried this code but am getting following error
    Access is denied.


    Line (17): "oXMLHTTP.Send sPostData".

    ReplyDelete