TESTEVERYTHING

Sunday, 26 June 2011

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:
Application Layer - DNS, TLS/SSL, TFTP, FTP, HTTP, IMAP, IRC,
NNTP, POP3, SIP, SMTP, SNMP, SSH, TELNET, BitTorrent, RTP,
rlogin.
Transport Layer- TCP, UDP, DCCP, SCTP, IL, RUDP,
Network Layer - IP (IPv4, IPv6), ICMP, IGMP, ARP, RARP, …
Link Ethernet Layer- Wi-Fi, Token ring, PPP, SLIP, FDDI, ATM,
DTM, Frame Relay, SMDS,
• TCP (Transmission Control Protocol)
– Enables two devices to establish a connection and exchange data.
– In the Internet protocol suite, TCP is the intermediate layer
between the Internet Protocol below it, and an application above it.
Applications often need reliable pipe-like connections to each other,
whereas the Internet Protocol does not provide such streams, but
rather only unreliable packets. TCP does the task of the transport
layer in the simplified OSI model of computer networks.
– It is one of the core protocols of the Internet protocol suite. Using
TCP, applications on networked hosts can create connections to one
another, over which they can exchange data or packets. The
protocol guarantees reliable and in-order delivery of sender to
receiver data. TCP also distinguishes data for multiple, concurrent
applications (e.g. Web server and e-mail server) running on the
same host.
• IP
– Specifies the format of data packets and the addressing protocol.
The Internet Protocol (IP) is a data-oriented protocol used for
communicating data across a packet-switched internet work. IP is a
network layer protocol in the internet protocol suite. Aspects of IP
are IP addressing and routing. Addressing refers to how end hosts
become assigned IP addresses. IP routing is performed by all hosts,
but most importantly by internetwork routers
• IP Address
– A unique number assigned to each connected device, often assigned
dynamically to users by an ISP on a session-by-session basis –
dynamic IP address. Increasingly becoming dedicated, particularly
with always-on broadband connections – static IP address.
Packet
– A portion of a message sent over a TCP/IP Network. It contains
content and destination
• HTTP (Hypertext Transfer Protocol)
– Underlying protocol of the World Wide Web. Defines how messages
are formatted and transmitted over a TCP/IP network for Web
sites. Defines what actions Web servers and Web browsers take in
response to various commands.
– HTTP is stateless. The advantage of a stateless protocol is that hosts
don't need to retain information about users between requests, but
this forces the use of alternative methods for maintaining users'
state, for example, when a host would like to customize content for
a user who has visited before. The common method for solving this
problem involves the use of sending and requesting cookies. Other
methods are session control, hidden variables, etc
– example: when you enter a URL in your browser, an HTTP
command is sent to the Web server telling to fetch and transmit the
requested Web page
o HEAD: Asks for the response identical to the one that
would correspond to a GET request, but without the
response body. This is useful for retrieving metainformation
written in response headers, without
having to transport the entire content.
o GET : Requests a representation of the specified
resource. By far the most common method used on
the Web today.
o POST : Submits user data (e.g. from a HTML form) to
the identified resource. The data is included in the
body of the request.
o PUT: Uploads a representation of the specified
resource.
o DELETE: Deletes the specified resource (rarely
implemented).
o TRACE: Echoes back the received request, so that a
client can see what intermediate servers are adding or
changing in the request.
o OPTIONS:
o Returns the HTTP methods that the server supports.
This can be used to check the functionality of a web
server.
o CONNECT: For use with a proxy that can change to
being an SSL tunnel.
• HTTP pipelining
– appeared in HTTP/1.1. It allows clients to send multiple requests at
once, without waiting for an answer. Servers can also send multiple
answers without closing their socket. This results in fewer
roundtrips and faster load times. This is particularly useful for
satellite Internet connections and other connections with high
latency as separate requests need not be made for each file. Since it
is possible to fit several HTTP requests in the same TCP packet,
HTTP pipelining allows fewer TCP packets to be sent over the
network, reducing network load. HTTP pipelining requires both the
client and the server to support it. Servers are required to support it
in order to be HTTP/1.1 compliant, although they are not required
to pipeline responses, just to accept pipelined requests.
• HTTP-Tunnel
– technology allows users to perform various Internet tasks despite
the restrictions imposed by firewalls. This is made possible by
sending data through HTTP (port 80). Additionally, HTTP-Tunnel
technology is very secure, making it indispensable for both average
and business communications. The HTTP-Tunnel client is an
application that runs in your system tray acting as a SOCKS server,
managing all data transmissions between the computer and the
network.
• HTTP streaming
– It is a mechanism for sending data from a Web server to a Web
browser in response to an event. HTTP Streaming is achieved
through several common mechanisms. In one such mechanism the
web server does not terminate the response to the client after data
has been served. This differs from the typical HTTP cycle in which
the response is closed immediately following data transmission.
The web server leaves the response open such that if an event is
received, it can immediately be sent to the client. Otherwise the
data would have to be queued until the client's next request is made
to the web server. The act of repeatedly queing and re-requesting
information is known as a Polling mechanism. Typical uses for
HTTP Streaming include market data distribution (stock tickers),
live chat/messaging systems, online betting and gaming, sport
results, monitoring consoles and Sensor network monitoring.
HTTP referrer
– It signifies the webpage which linked to a new page on the Internet.
By checking the referer, the new page can see where the request
came from. Referer logging is used to allow websites and web
servers to identify where people are visiting them from, for
promotional or security purposes. Since the referer can easily be
spoofed (faked), however, it is of limited use in this regard except
on a casual basis. A dereferer is a means to strip the details of the
referring website from a link request so that the target website
cannot identify the page which was clicked on to originate a request.
Referer is a common misspelling of the word referrer. It is so
common, in fact that it made it into the official specification of
HTTP – the communication protocol of the World Wide Web – and
has therefore become the standard industry spelling when
discussing HTTP referers.

Saturday, 25 June 2011

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 ("This is a test.")
   ' Close the file to writing.
   f1.Close
   Response.Write "Moving file to c:\tmp <br>"
   ' Get a handle to the file in root of C:\.
   Set f2 = fso.GetFile("c:\testfile.txt")
   ' Move the file to \tmp directory.
   f2.Move ("c:\tmp\testfile.txt")
   Response.Write "Copying file to c:\temp <br>"
   ' Copy the file to \temp.
   f2.Copy ("c:\temp\testfile.txt")
   Response.Write "Deleting files <br>"
   ' Get handles to files' current location.
   Set f2 = fso.GetFile("c:\tmp\testfile.txt")
   Set f3 = fso.GetFile("c:\temp\testfile.txt")
   ' Delete the files.
   f2.Delete
   f3.Delete
   Response.Write "All done!"
End Sub

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 next line (carriage return/line feed). Be aware that the end of some strings may already have such nonprinting characters.
The following example demonstrates how to open a file, use all three write methods to add data to the file, and then close the file:
[VBScript]
Sub CreateFile()
   Dim fso, tf
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set tf = fso.CreateTextFile("c:\testfile.txt", True)
   ' Write a line with a newline character.
   tf.WriteLine("Testing 1, 2, 3.") 
   ' Write three newline characters to the file.        
   tf.WriteBlankLines(3) 
   ' Write a line.
   tf.Write ("This is a test.") 
   tf.Close
End Sub

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", trThe 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.OpenTextFile("c:\\test.txt", ForWriting, true);
A third way to create a text file is to use the OpenAsTextStream method with the ForWriting flag set.
[VBScript]
Dim fso, f1, ts
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile ("c:\test1.txt")
Set f1 = fso.GetFile("c:\test1.txt")
Set ts = f1.OpenAsTextStream(ForWriting, True

Wednesday, 22 June 2011

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 TableRowcount -1
 dtmCurrRow  = TableObject.GetcellData(i,<DateColumn>)

 dtmNextRow  =  = TableObject.GetcellData(i+1,<DateColumn>)
      If  NOT cdate(dtmCurrRow) <=  cdate(dtmNextRow) Then
              Flage = 1
              Exit For
      End If
End
If  Flage <> 1 than
  msgbox  "Pass"
Else
  msgbox  "Fail"
End if

Friday, 17 June 2011

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


Wednesday, 15 June 2011

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 that live in
       ‘the same city as John Smith so that he can arrange rides home with them.
       ‘First, the example finds the table row containing
      ‘”John Smith”. Then it checks the value of the CityColumnn cell to determine
       ‘the city in which John lives. It searches the table cells to find all other
        ‘employees that live in that city. Finally it uses the GetCellData method to
        ‘return those employees names and, using a function, generates a list
         ‘containing those names.

  CityColumn = 4
  NameColumn = 2

‘Get the row number for employee ‘John Smith’
RowNumber = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetRowWithCellText(“John Smith”)
Set AccommodationsCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(RowNumber, CityColumn, “WebEdit”, 0)
TableRows = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).RowCount
‘Search for all employees that live in the same city as ‘John Smith’ and add them to his ride home list
For i = 1 To TableRows
   Set CurrentCity =    Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(i, CityColumn, “WebEdit”, 0)
    If CurrentCity.GetROProperty(“value”) = AccommodationsCity.GetROProperty(“value”) Then
      EmployeeName =  Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetCellData(i, NameColumn)
      AddToJohnSmithRideHomeList (EmployeeName)
     End If

 Next
End Sub

Translate







Tweet