Posts

Web Terminologies Part 1

• Internet – A global network connecting millions of computers. • World Wide Web (the Web) – An information sharing model that is built on top of the Internet, utilizes HTTP protocol and browsers (such as Internet Explorer) to access Web pages formatted in HTML that are linked via hyperlinks and the Web is only a subset of the Internet (other uses of the Internet include email (via SMTP), Usenet, instant messaging and file transfer (via FTP) • URL (Uniform Resource Locator) – The address of documents and other content on the Web. It is consisting of protocol, domain and the file. Protocol can be either HTTP, FTP, Telnet, News etc., domain name is the DNS name of the server and file can be Static HTML, DOC, Jpeg, etc., . In other words URLs are strings that uniquely identify resources on internet. • TCP/IP – TCP/IP protocol suite used to send data over the Internet. TCP/IP consists of only 4 layers - Application layer, Transport layer, Network layer & Link layer Internet Protocols: ...

Moving, Copying, and Deleting Files Working with files(FileSystemObject) / QTP

Moving, Copying, and Deleting Files The FSO object model has two methods each for moving, copying, and deleting files, as described in the following table. Task Method Move a file File.Move or FileSystemObject.MoveFile Copy a file File.Copy or FileSystemObject.CopyFile Delete a file File.Delete or FileSystemObject.DeleteFile The following example creates a text file in the root directory of drive C, writes some information to it, moves it to a directory called \tmp, makes a copy of it in a directory called \temp, then deletes the copies from both directories. To run the following example, create directories named \tmp and \temp in the root directory of drive C : [VBScript] Sub ManipFiles    Dim fso, f1, f2, s    Set fso = CreateObject("Scripting.FileSystemObject")    Set f1 = fso.CreateTextFile("c:\testfile.txt", True)    Response.Write "Writing file <br>"    ' Write a line.    f1.Write...

Adding Data to the File Working with files(FileSystemObject) / QTP

Adding Data to the File Once the text file is created, add data to the file using the following three steps: Open the text file. Write the data. Close the file. To open an existing file, use either the OpenTextFile method of the FileSystemObject object or the OpenAsTextStream method of the File object. To write data to the open text file, use the Write , WriteLine , or WriteBlankLines methods of the TextStream object, according to the tasks outlined in the following table Task Method Write data to an open text file without a trailing newline character.       Write Write data to an open text file with a trailing newline character. WriteLine Write one or more blank lines to an open text file. WriteBlankLines To close an open file, use the Close method of the TextStream object. Note The newline character contains a character or characters (depending on the operating system) to advance the cursor to the beginning of the nex...

Creating Files Working with files(FileSystemObject) / QTP

Creating Files There are three ways to create an empty text file (sometimes referred to as a “text stream”). The first way is to use the CreateTextFile method. The following example demonstrates how to create a text file using the CreateTextFileMethod method. [VBScript] Dim fso, f1 Set fso = CreateObject("Scripting.FileSystemObject") Set f1 = fso.CreateTextFile("c:\testfile.txt", True) [JScript] var fso, f1; fso = new ActiveXObject("Scripting.FileSystemObject"); f1 = fso.CreateTextFile("c:\\testfile.txt", tr The second way to create a text file is to use the OpenTextFile method of the FileSystemObject object with the ForWriting flag set. [VBScript Dim fso, ts Const ForWriting = 2 Set fso = CreateObject("Scripting. FileSystemObject") Set ts = fso.OpenTextFile("c:\test.txt", ForWriting, True) [JScript] var fso, ts; var ForWriting= 2; fso = new ActiveXObject("Scripting.FileSystemObject") ts = fso.OpenTe...

Validation of Sorting in WEBTABLE / QTP

Hi All, Some time in application we have to verify the sorting functionality.In Web table for each column we need to click and check is it working fine or not. Here i am giving an example of sorting the date column. but it will verify in ascending order. logic for this:   1. Click on Date column which sort the date in ascending order.   2. Get first row and second row date value form Date column   3. Check first row date should be less than or equal to second row date.   4. Get second row and third row date value.   5. Check second row date should be less than or equal to third row date value.   6. Same way check until end of row using For Loop.   7. In the case if you got false result while comparison two row you need to break the for loop and show  the   fail result...... set TableObject = Browser(“XYZ”).Page(“WXY”).WebTable(“MNP”) TableRowcount  = Browser(“XYZ”).Page(“WXY”).WebTable(“MNP”).RowCount For i =1 to TableRow...

Read Value from Registory / QTP / WScript

Here an example to get get the location where QTP is installed REM Create shell script object   Set WshShell = CreateObject(“WScript.Shell”) REM in variable store the registry key path   sKey =”HKLM\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\Packages\WebFormsPackage\Settings\ConfigurationFile” REM here using the shell object we can read the registry key value sQTPpath= WshShell.RegRead(sKey) msgbox sQTPpath set WshShell = nothing

Get cell data from webtable / QTP

Hi all , I found a helpful example in QTP  help file that can be use most of time while working with web table. I hope It will help you. Description        Returns the text contained in the specified cell. Syntax    object .GetCellData ( Row , Column ) Argument Description object A test object of type WebTable . Row Required. A Variant value. The row number where the cell is located. The first row in the table is numbered 1. Column Required. A Variant value. The column number where the cell is located. The first column in the table is numbered 1. Return Value A String value.  Returns the data contained in the specified cell. If the specified cell is not valid, the method returns micCellDoesNotExist Find All Employees That Live in the Same City Sub GetCellData_GetRowWithCellText_Example()         ‘The following example retrieves the names of all employees tha...