Friday, May 29, 2009

Connection string in QTP?

connection string is a string that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying driver or provider in order to initiate the connection.

Connections are built by supplying an underlying driver or provider with a connection string, which is a way of addressing a specific database or server and instance as well as user authentication credentials (for example, Server=sql_box;Database=Common;User ID=uid;Pwd=password;). Once a connection has been built it can be opened and closed at will, and properties (such as the command time-out length, or transaction, if one exists) can be set. The Connection String is composed of a set of key/value pairs as dictated by the data access interface and data provider being used.


Client Side and Server Side Applications

Client side scripting languages are Javascript, VbScript, PHP…etc
Client side scripting languages are useful to validate the inputs or user actions from user side or client side.
Client side scripting is good because it won’t send the unwanted input’s to server for validation. From front-end it self it validate the user inputs and restricts the user activities and guides him

Server side Scripting languages are
Perl, JSP, ASP, PHP.etc
Server side Scripting languages are to validate the inputs at server side.

These scripting languages provide security for the application. And also provides dynamic nature to web or client server application

Thursday, May 28, 2009

Whats the difference between HTTP and HTTPS?

http is hyper text transfer protocol which is responsible for transmitting and receiving information across the Internet where as https is secure http, which is used exchanging confidential information with a server, which needs to be secured in order to prevent unauthorized access.

HTTP is Hyper Text Transport Protocol and is transmitted over the wire via PORT 80(TCP). You normally use HTTP when you are browsing the web, it's not secure, and so someone can eavesdrop on the conversation between your computer and the web server. HTTP can support the client asking for a particular file to be sent only if it has been updated after a certain date and time. This would be used if the client has already retrieved a copy of a file by that name from that server, but wants to check to see if it has been updated since then. The server responds either with the updated file, with a message to say the file has not been changed, or with a message that the file no longer exists.

HTTPS (Hypertext Transfer Protocol over Secure Socket Layer or HTTP over SSL) is a Web protocol developed by Netscape and built into its browser that encrypts and decrypts user page requests as well as the pages that are returned by the Web server. HTTPS is really just the use of Netscape's Secure Socket Layer (SSL) as a sub layer under its regular HTTP application layering. (HTTPS uses port 443 instead of HTTP port 80 in its interactions with the lower layer, TCP/IP.) SSL uses a 40-bit key size for the RC4 stream encryption algorithm, new-age browsers use 128-bit key size which is more secure than the former, it is considered an adequate degree of encryption for commercial exchange. HTTPS is normally used in login pages, shopping/commercial sites.

How it Work
Https is not a separate protocol, but refers to the combination of a normal HTTP interaction over an encrypted Secure Sockets Layer (SSL) or Transport Layer Security (TLS) transport mechanism. This ensures reasonable protection from eavesdroppers and (provided it is implemented properly and the top level certification authorities do their job properly) man-in-the-middle attacks.

The default TCP port of an https: URL is 443 (for unsecured HTTP, the default is 80). To prepare a web-server for accepting https connections the administrator must create a public key certificate for the web-server. These certificates can be created for Linux based servers with tools such as Open SSL's ssl or SuSE's gensslcert. This certificate must be signed by a certificate authority of one form or another, who certifies that the certificate holder is who they say they are. Web browsers are generally distributed with the signing certificates of major certificate authorities, so that they can verify certificates signed by them.

When does Test Automation Makes Sense

1.When there is a repetitive task
2.When you want to do load test an application
3.API based testing
advantages:
4.Human errors will be minimized
5.Reusability
6.Number of resources will be reduced
7.Consistency in test results

Tuesday, May 26, 2009

Connect to Oracle DataBase using QTP

'Reference: Microsoft ActiveX Data Objects 2.7 library

'Dim cnn As ADODB.Connection
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.RecordSet")

' Open a connection by referencing the ODBC driver in sql server
' cnn.ConnectionString = "driver={SQL Server};&server=MySqlServer;uid=MyUserName;pwd=MyPassword;database=pubs"
'cnn.Open

' Open a Connection using an ODBC for oracle
cnn.ConnectionString = "DRIVER={Microsoft ODBC for Oracle};DSN=real;UID=gopi;PWD=orcl;"
cnn.ConnectionTimeout = 30
cnn.Open

' Find out if the attempt to connect worked.
If cnn.State = adStateOpen Then ' or cnn.State=1
MsgBox "connected to database"
Else
MsgBox "connectin failed.."
End If

'execute sql query
rs.Open "SELECT * FROM promotion.t_p_promo_master WHERE f_promo_id = 60082", cnn

' Create a Recordset by executing an SQL statement.
' Set rs = cnn.Execute("Select * From authors")
'Remember that the returned Recordset object from connection.execute is always a read-only,
'forward-only cursor. If you need a Recordset object with more functionality, you should
'first create a Recordset object with the desired property settings and then use the
'Recordset object's Open method to execute the query and return the desired cursor type.

' Send a Delete statement to the database.
'cnn.Execute ("Delete From authors Where au_id = '011-01-0111'")

' Find out how many rows were affected by the Delete.
'Set rs = cnn.Execute("Select @@rowcount")
' Display the first field in the recordset.
'MsgBox rs(0) & " rows deleted"
'in above the command passed to the data source is a Delete statement. Because no rows are returned, you do not need to explicitly use a Recordset object. How many rows were deleted? You can use the recordsAffected parameter to find out.

'Running stored prcedure
' Create a recordset by running a stored procedure.
' Set rs = cnn.Execute("Exec byroyalty 50")

Do While Not rs.EOF
'copy each field
'Worksheets("Sheet1").Range("A3").End(xlDown).Offset(1, 0) = rs.Fields(0)

'display each field in the record set
For Each Field In rs.Fields
MsgBox Field
Next
rs.MoveNext

Loop

' Close the connection.
cnn.Close

TestCases on Physical Objects like Pen,Book or Chair etc

Test cases on different objects generally asking are ::Pen, Book,Chair .
In general when we are writing a test case for objects like above, we should consider the objects parameters like
• Look and feel
• Performance
• Usability
• Rigidity
Look and feel means external appearance like outer case must be attractive. Look and feel parameters are, Color, Height, Width, Design Material used for making it, .etc
If you come for performance the important parameters are, Durability, Continuous perfromence...Etc.
Usability: How easy to use that thin Accessibility
Rigidity How strong it is How it is working in abnormal conditions For example if you want to write test cases for a pen Then first start with look and feel.
If you com for software enabled objects Notepad, Yahoo login, For above objects we should check Different menu options are working properly Functionality of buttons, Memory capacities, Look and feel, Speed of operation…etc

Friday, May 22, 2009

Retrieve the nth highest salary from emp table?

Oracle10g:
SELECT * FROM emp e1 WHERE &N = (SELECT COUNT(DISTINCT (e2.salary)) FROM emp e2 WHERE e2.salary >= e1.salary)

sqlserver

select max(sal) FROM emp where not in(select top n sal from emp)order by sal desc;
N -> Nth highest salary of the month

Reterieving the Top2 salaries from the employee table:
Select * from EMP e where 2>= (select count (*) from EMP e where sal>e.sal) order by desc sal

Thursday, May 21, 2009

Dynamic arrays in QTP?

You can use the Dim statement to declare an array with empty parentheses to declare a dynamic array. You use the Preserve keyword to preserve the data in an existing array when you change the size of the last dimension

Dim a() ' Allocates nothing.we can't declare array as a(2) and resize it to a(4)
ReDim preserve a(0)
a(0) = 0
ReDim preserve a(1)
a(1) = 1
ReDim preserve a(2)
a(2) = 2
ReDim preserve a(3)
a(3) = 3
ReDim preserve a(4) ' to preserve the contents of the array as the resizing takes place.
a(4)= 4
For each ite in a
msgbox ite ' o/p : 0 1 2 3 4
Next

Arrays in QTP

Dim a(3) ' Allocates the fixed storage space. can't be changed dynamically when array size fixed.
a(0) = 0
a(1) = 1
a(2) = 2
a(3) = 3
'a(4)= 4 'subscript out of range error
For each ite in a
msgbox ite ' o/p : 0 1 2 3
Next
Erase a ' Each element is reinitialized and Free memory used by array.

Retrieve the nth highest salrary from an employee table?