Quick test professional

QTP Tips QTP codes QTP Faqs and more

Can we create the window application with VBScipt?

Can we create the window application with VBScipt?

yes: using HTML Application (HTA)

An HTML Application (HTA) is a Microsoft Windows application written with HTML and Dynamic HTML. The ability to write HTAs was introduced with Microsoft Internet Explorer 5.0.

HTAs can be made from regular HTML files by simply changing the file extension to .hta. A regular HTML file is confined to the security model of the web browser – i.e. to communicating with the server, manipulating the page’s object model (usually to validate forms and / or create interesting visual effects) and reading / writing cookies. An HTA runs as a fully trusted application and therefore has more privileges than a normal HTML file – for example an HTA can create / edit / remove files and registry entries.

To customize the appearance of an HTA, a new tag, with attributes, is introduced: <hta:application …>. This tag appears in the <head>…</head> section of an HTA document.

Because an HTA has more privileges than an HTML page, it cannot be executed via http. Rather, the HTA must be downloaded (just like an EXE file) and executed from local file system.

 QTP code Generates for a HTML Application

QTP generates the code as similar to the normal web applications, except that it shows window instead of browser 

Example: If the  HTML Application has a edit box then code will be

Window(..).Webedit(…).set “value”

Sample code :

This example code creates a HTML app with 3 edit boxes.

<SCRIPT Language=”VBScript”>
Sub SetNameColor

If Len(UserName.Value) <> 0 Then

UserName.style.background = “cyan”

Else

UserName.style.background = “yellow”

End If

End Sub

</SCRIPT>

<body>

Name<br>

<input type=”text” name=”UserName” size=”25″ style=”background-color:yellow” onChange=”SetNameColor”><p>

Address<br>

<input type=”text” name=”Address” size=”25″><p>

Phone<br>

<input type=”text” name=”Phone” size=”25″><p>

</body>

For More information on HTML Application Refer:

http://msdn2.microsoft.com/en-us/library/ms536496.aspx

http://www.microsoft.com/technet/scriptcenter/resources/qanda/htas.mspx

References:MSDN 

Advertisements

February 15, 2008 Posted by | Extra Topics | 2 Comments