QTP Not just for GUI anymore The true

  • Slides: 48
Download presentation
QTP: Not just for GUI anymore

QTP: Not just for GUI anymore

The true beauty of QTP is that the only limitation is your imagination and

The true beauty of QTP is that the only limitation is your imagination and ability to code in VBScript.

Topics n n Web Services Telnet FTP XML

Topics n n Web Services Telnet FTP XML

Advantages using APIs n Accessing non-GUI applications via API directly: q q Increases test

Advantages using APIs n Accessing non-GUI applications via API directly: q q Increases test execution speed Reduces synchronization problems related to GUI window like Telnet, DOS CMD, Pu. TTY, Exceed, etc. Allows execute scripts on locked boxes No need for QTP add-ins

Let’s talk about Component Object Model (COM) first COM is used by developers to

Let’s talk about Component Object Model (COM) first COM is used by developers to create reusable software components, link components together to build applications, and take advantage of Windows services. The family of COM technologies includes: n COM+ n Distributed COM (DCOM) n Active. X Controls.

COM methods and properties n COM properties and methods Properties don’t take any arguments

COM methods and properties n COM properties and methods Properties don’t take any arguments and can be read/write value = object. property (read) object. property = value (write) q Methods are read only if they returns value = object. method() (returns value) Set RS = Conn. Execute(“Select * From Tbl") (returns object) Conn. Close (returns no value) tdc. Login “username", “psw" (method with parameters, returns no value) q

VBScript Create. Object function creates and returns a reference to an Automation object Create.

VBScript Create. Object function creates and returns a reference to an Automation object Create. Object(servername. typename [, location]) Example connecting to Quality Center (QC): Set tdc = Create. Object ("TDApi. Ole 80. TDConnection") tdc. Init. Connection. Ex s. Server. Name 'Connect tdc. Login s. User, s. Password tdc. Connect s. Domain, s. Project

COM objects in Registry editor

COM objects in Registry editor

Resources: n n Microsoft “COM: Component Object Model Technologies” www. microsoft. com/default. mspx “COM

Resources: n n Microsoft “COM: Component Object Model Technologies” www. microsoft. com/default. mspx “COM for ASP Programmers” By Wayne Berry http: //www. 15 seconds. com/Issue/971214. htm

File Transfer Protocol (FTP)

File Transfer Protocol (FTP)

Using Win. Inet API for FTP n Windows Win. INet. DLL enables applications to

Using Win. Inet API for FTP n Windows Win. INet. DLL enables applications to interact with the following protocols: q q q FTP HTTP Gopher

Win. Inet FTP hierarchy

Win. Inet FTP hierarchy

FTP: File download steps 1. 2. 3. 4. Open an FTP session with Internet.

FTP: File download steps 1. 2. 3. 4. Open an FTP session with Internet. Open function. The function returns a session handle. Connect to the host by calling the Internet. Connect function using session handle. It returns a connection handle. Call the Ftp. Get. File function to get the file. Close the handles created in Steps 1 and 2, using the Internet. Close. Handle function

FTP: File download Script

FTP: File download Script

FTP: File download is successful

FTP: File download is successful

Active. X components (COM) for FTP n The are numerous Active. X (COM) components

Active. X components (COM) for FTP n The are numerous Active. X (COM) components for FTP free and not free: q q q by Chilkat Software www. chilkatsoft. com by Easewe Software www. easewe. com by X 360 Software www. x 360 soft. com by Dart Communications www. dart. com etc.

FTP: Download file using Chilkat’s Active. X component (COM)

FTP: Download file using Chilkat’s Active. X component (COM)

Resources: “FTP your scripts” by Dani Vainstein www. advancedqtp. com n “Creating an FTP

Resources: “FTP your scripts” by Dani Vainstein www. advancedqtp. com n “Creating an FTP Component in Visual Basic” By Jeff Niblack www. 15 seconds. com n

Telnet to Unix/Linux using COM objects

Telnet to Unix/Linux using COM objects

A little bit of history A while back I had to automate a Client/Server

A little bit of history A while back I had to automate a Client/Server application and execute quite a few UNIX commands on a backend. After trying several things, like Pu. TTY, TE Add-in, Exceed, etc. Exceed worked decent enough, but it was a complicated solution. I had to use "Capture to File" feature and then parse the file. After working with Load. Runner Win. Sock protocol for Telnet interface I start looking for Win. Sock (Active. X) COM interface that can be used in QTP The goal was to connect to Unix/Linux box bypassing external GUI applications and execute scripts on locked boxes. Another reason was that QTP has problems with Get. Visible. Text method.

Active. X components (COM) for Telnet n The are numerous Active. X (COM) components

Active. X components (COM) for Telnet n The are numerous Active. X (COM) components for Telnet free and not free: q q by Dimac Development www. dimac. net Easy. Com 3. 1 www. sharewareconnection. com/easycom. htm by Dart Communications www. dart. com etc.

Dimac w 3 sockets DLL methods and properties COM Object - socket. tcp Buffer

Dimac w 3 sockets DLL methods and properties COM Object - socket. tcp Buffer : String Do. Telnet. Emulation : Boolean Host : String Telnet. Emulation : String Time. Out : Integer Close() : Get. Line() : String Get. Text( len ) : String Open() : Send. Line( Line ) : Send. Text( text ) : Wait() : Wait. For( Substring ) : Boolean Wait. For. Disconnect() :

Dimac W 3 Socket API installation n n You need to download W 3

Dimac W 3 Socket API installation n n You need to download W 3 Socket Dll to your location and register it using Socket. Reg. exe included in a zip file. Note: Readme said that you need to download winsock 2 also - ignore it. The full W 3 Sockets reference is located: http: //www. dimac. net/Products/Free. Products/w 3 Sockets/Reference/Refstart. htm n

Example for Unix/Linux n The function on next slide: q q n connect to

Example for Unix/Linux n The function on next slide: q q n connect to Unix/Linux box via Telnet navigates to Test. Directory executes “grep” command returns “grep” results You can also find more examples on Web: q q http: //www. tek-tips. com/viewthread. cfm? qid=938038&page=3 http: //www. mediamonkey. com/forum/viewtopic. php? t=21124

W 3 Sockets API limitation n This API has a problem with Send. Line

W 3 Sockets API limitation n This API has a problem with Send. Line method when sending over 80 characters.

Web Services and XML

Web Services and XML

Web Services architecture

Web Services architecture

HP/Mercury Solutions for Web. Services n n The HP Service Test software – is

HP/Mercury Solutions for Web. Services n n The HP Service Test software – is a SOA testing solution that simplifies and accelerates the automated functional testing of SOA services. HP Service Test Management module plugs into Quality Center QTP Web Services add-in

Windows APIs for Web Services n HP Service Test and QTP Web Services Add

Windows APIs for Web Services n HP Service Test and QTP Web Services Add -in are great solutions for comprehensive Web Services testing. However, the lightweight solution using Windows APIs works perfect in most cases.

Win. HTTP DLL n n Microsoft Windows HTTP Services (Win. HTTP) provides developers with

Win. HTTP DLL n n Microsoft Windows HTTP Services (Win. HTTP) provides developers with a server -supported, high-level interface to the HTTP/1. 1 Internet protocol. Win. HTTP Win. Http. Request COM object uses Winhttp. dll

Win. Http. Request. 5. 1 Methods and Properties Methods of Win. Http n Abort:

Win. Http. Request. 5. 1 Methods and Properties Methods of Win. Http n Abort: Aborts a Win. HTTP Send method. n Get. All. Response. Headers: Retrieves all HTTP response headers. n Get. Response. Header: Retrieves the HTTP response headers. n Open: Opens an HTTP connection to an HTTP resource. n Send: Sends an HTTP request to an HTTP server. n Set. Auto. Logon. Policy: Sets the current Automatic Logon Policy. n Set. Client. Certificate: Selects a client certificate to send to a Secure Hypertext Transfer Protocol (HTTPS) server. n Set. Credentials: Sets credentials to be used with an HTTP server—either an origin or a proxy server. n Set. Proxy: Sets proxy server information. n Set. Request. Header: Adds, changes, or deletes an HTTP request header. n Set. Timeouts: Specifies, in milliseconds, the individual time-out components of a send/receive operation. n Wait. For. Response: Specifies the wait time, in seconds, for an asynchronous Send method to complete, with optional time-out value. Properties of Win. Http n Option: Sets or retrieves a Win. HTTP option value. n Response. Body: Retrieves the response entity body as an array of unsigned bytes. n Response. Stream: Retrieves the response entity body as an IStream. n Response. Text: Retrieves the response entity body as a string. n Status: Retrieves the HTTP status code from the last response. n Status. Text: Retrieves HTTP status text.

Change. Metric. Weight. Unit Web Service on-line http: //www. webservicex. net/convert. Metric. Weight. asmx

Change. Metric. Weight. Unit Web Service on-line http: //www. webservicex. net/convert. Metric. Weight. asmx

Change. Metric. Weight. Unit Web Service WSDL

Change. Metric. Weight. Unit Web Service WSDL

Using Http. Win. Http. Request. 5. 1 for Web. Services

Using Http. Win. Http. Request. 5. 1 for Web. Services

Win. Http. Request. 5. 1 snippet ' Win. Http. Request. 5. 1 Object Set

Win. Http. Request. 5. 1 snippet ' Win. Http. Request. 5. 1 Object Set o. Win. Http. Req = Create. Object("Win. Http. Request. 5. 1") o. Win. Http. Req. Open "POST", s. Web. Service_Url, False o. Win. Http. Req. set. Request. Header "Content-Type", s. Content. Type o. Win. Http. Req. set. Request. Header "SOAPAction", s. SOAPAction 'Send SOAP request o. Win. Http. Req. Send s. SOAP_Request 'Get XML Response s. XMLResponse = o. Win. Http. Req. Response. Text

SOAP XML Response

SOAP XML Response

Off topic: Using Win. HTTP for Web pages

Off topic: Using Win. HTTP for Web pages

HTML Response

HTML Response

Msxml 2. DOMDocument n n A DOM for XML is an object model that

Msxml 2. DOMDocument n n A DOM for XML is an object model that exposes the contents of an XML document We use the XML DOM by creating an instance of an XML parser Create. Object(“Msxml 2. DOMDocument ”) is the method to create an instance of the Parser object Msxml 2. DOMDocument COM object uses Msxml. dll

XML Request file

XML Request file

Using Msxml 2. DOMDocument to load XML file

Using Msxml 2. DOMDocument to load XML file

Msxml 2. DOMDocument Code Snippet 'l. Msxml 2. DOMDocument Set o. Input. Xml. Doc

Msxml 2. DOMDocument Code Snippet 'l. Msxml 2. DOMDocument Set o. Input. Xml. Doc = Create. Object("Msxml 2. DOMDocument") 'load. XML from file o. Input. Xml. Doc. load("C: XML_Files_DemoWeight_Conversion. xml") … … 'Send SOAP request o. Win. Http. Req. Send o. Input. Xml. Doc

QTP XML Objects n n n n XMLUtil Object XMLAttributes. Coll Object XMLData Object

QTP XML Objects n n n n XMLUtil Object XMLAttributes. Coll Object XMLData Object XMLElements. Coll Object XMLFile Object XMLItem. Coll Object

Example: Compare XML files using QTP objects

Example: Compare XML files using QTP objects

Comparison results

Comparison results

Resources: n n n MSDN http: //msdn. microsoft. com/enus/library/aa 384109. aspx Stefan Thelenius about

Resources: n n n MSDN http: //msdn. microsoft. com/enus/library/aa 384109. aspx Stefan Thelenius about Software Testing http: //abouttesting. blogspot. com Quick. Test Professional Help file

Igor Gershovich n n n E-Mail: igershovich@connectedtesting. com Phone: 720 -933 -9395 www. connectedtesting.

Igor Gershovich n n n E-Mail: igershovich@connectedtesting. com Phone: 720 -933 -9395 www. connectedtesting. com