Skip to main content

Posts

Showing posts with the label Test Partner

SHDocVw.ShellWindows stopped working on Vista

I have the following code to enumerate running instance of IE 7(not sure if this works with IE6). Sub TestGetRunningIE() Dim sws As SHDocVw.ShellWindows Dim ie As SHDocVw.InternetExplorer Set sws = New SHDocVw.ShellWindows For Each ie In sws Debug.Print ie.Name Next End Sub For the above code to work, need to make a reference to shdocvw.dll, see below for the location: When I moved this code in Vista SP1 Business it stopped working. Who would think that this is related to UAC :)... anyway just disable UAC and this code should work again. Note that on one of my machines it is working with UAC on :(.... See this post to disable UAC . This is only one of the methods to disable User Account Control. ~ts

Get treeview item information using VBA

Test Partner is quite flexible in handling treeview control. But there are times when you need to have a finer control of the object. The purpose of this blogpost is to document how to get treeview item information using Win32 api. The code below is a class module that now supports getting the text of root and currently selected item. It also allows the user to check whether the item is expanded or not. See below for the code. For demonstration purposes, save this as TWin32TreeView class module under common project (I am referring to Test Partner here). Below is a sample test script to use the class module. You can save this as "scratch" under common project. Enjoy! Note: For better result, use Notepad++ when copying source code from clipboard. The builtin Notepad.exe is not up to the job. You may check latest copy from http://tscodesnippets.googlecode.com/svn/tpcodesnippets/trunk/ or browse source from svn repository here . TechnoS

How to provide MSAA Name for MFC edit controls

Microsoft Active Accessibility (MSAA) can be used in GUI test automation or for accessibility. For test automation purposes, IAccessible::get_accName can be used to retrieve name of an edit box. To make this to work for MFC based applications, the tab order sequence should be modified such that the static label at the left of the edit box is one number lower. For example, if the edit box's tab order number is 5, the static label on the left should have tab order of 4. For MFC based application created using VS2010, menu Format | Tab Order (Ctrl + D) should show the order sequence graphically. Note that this is applicable to the following test automation tools/frameworks: - Test Partner - Rational Robot - UI Automation Just to stress this out again, you need to have a static label to the left of the edit box for this work. Enjoy! References: http://msdn.microsoft.com/en-us/library/dd373597(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/dd318483(VS.85).aspx ~ts

Controlling Popup menu using Accessibility API

In my previous post I discussed about using Accessibility API to control Windows Start Menu. For this blogpost exercise we will control a popup menu using AA. For those who are familiar with VBA, they would know outright that class modules cannot use AddressOf operator within the class definition. In the spirit of Object Oriented programming, it would have been better to use solely class module for this but due to AddressOf requirements that it should be in a module then we will try to mix and match using both Class module and a module. The code is not a elegant as I hope it would be but this is the way VBA was designed. Now let us get our hands dirty, first we will create a class module named CPopupMenuController. This is a very simple class module, in the initialization section we set a hook to receive focus events coming from the system and remove the hook once the object is destroyed. See below for the code: '--------------------------------------------------------------

Start Menu handler using Accessibility API

The code below demonstrates how to run an application from Start menu using accessibility API in TestPartner making use of VBA. For this exercise, we will use Test Script, Class Module and Module. The original intent was to have the functionality built into class module and instantiate it in Test Script. But AddressOf operator does not work inside a class module in VBA hence using Module. Anyway, first let us define the class module. For this exercise name it CStartMenuController. See below for the code (save this as CStartMenuController): '------------------------------------------------------------------------------ ' Develop by : Techno.Scavenger ' Licensed to : Mankind ' Date : 26Oct2008 @ 1:39 AM + 8 GMT (Sunday @home) ' Warranty ' THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMEN

Change TestPartner script automatically

This is an ugly hack. Please be careful with this code as it is using an undocumented feature. Code below will allow you to modify a test script using VBA. Test script is an asset within TestPartner application, so if you are not using TP this may not apply to you. '------------------------------------------------------------------------------ ' Develop by : Techno.Scavenger ' Licensed to : Mankind ' Date : 11Oct2008 @ 6:55 PM + 8 GMT (Saturday @home) ' Warranty ' THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ' “Techno.Scavenger” OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY CLAIM, ' DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ' OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ' USE OR OTHER DEALINGS

Export TestPartner run into xml with xsl

TestPartner run results can be exported using command line, tpexport, or via File|Export from with TestPartner itself. Another way of exporting run results is via TestPartner.TLB automation. The beauty with TestPartner.TLB is that you can export with it the xsl. See below for the code. Option Explicit Sub TestTPResultDump() Dim t As New TPApp Dim pCount As Integer Dim p As Integer Dim sCount As Integer Dim sName As String Dim tp2 As TestPartner.TPProject2 t.Login "admin", "admin", "TestPartner_SQL", 1 pCount = t.Projects.Count For p = 1 To pCount If t.Projects.Item(p).Name = "ScratchProject" Then Debug.Print t.Projects.Item(p).Name Set tp2 = t.Projects.Item(p) Dim rc As Integer For rc = 1 To tp2.Results.Count If tp2.Results.Item(rc).Name = "scratch2" Then Debug.Print tp2.Results.Item(rc).Description

Handle popup menus manually in TestPartner

One of the areas where TestPartner 6.1.x is challenged in controlling application under test (AUT) is Popup Menus. It handles it one time but sometimes it complains that the menu is not detected but it is clearly infront of the screen. Though it is working ~80% of the time but Murphy's law has it that if anything can go wrong, it will. What I have come up so far is to handle popup menus manually. See below for the code, so far it seems to meet my needs. Option Explicit Private Declare Function SetCursorPos Lib "user32" _ (ByVal x As Long, ByVal y As Long) As Long Sub Main() 'open Windows Explorer in "My Computer" Window("Desktop Window").Attach ListView("Index=1").Select "CD Drive (E:)", tpMouseRight PopupMenuEx2 "Properties" Window("Application=Explorer.exe Classname='#32770'").Attach Button("Caption=OK").Click End Sub Private Function PopupMen

Test code

This is only a test of formatting source code in Blogger. See http://code.google.com/p/syntaxhighlighter/ for details. Use Notepad++ when copying source over from clipboard. Option Explicit Sub Main() Include "Common.TWin32TreeView" Dim wtv As TWin32TreeView 'Window("Desktop Window").Attach Window("Application=Explorer.exe ClassName=CabinetWClass TypeName=Window").Attach Set wtv = New TWin32TreeView wtv.Handle = TreeView("Index=1").hwnd Dim sMsg As String sMsg = "Root item is " & wtv.GetRootItemText sMsg = sMsg & vbCrLf & "Selected item is : " & wtv.GetSelectedItemText 'MsgBox sMsg If wtv.IsSelectedItemExpanded Then MsgBox "selected node is expanded" Else MsgBox "it is not yet expanded" End If End Sub

Detecting Classic Start Menu or Start Menu

On some of our regression tests, we need to check that all shortcuts that our product created under Windows Start Menu is working. One of the challenge this one presents is that user can set it to either "Classic Start Menu" or the new XP style Start Menu. Since our organization likes to use Visual Tests, I was looking for a way to detect what is the current style of Start Menu, hence the script below was born: 'Refs 'http://www.themssforum.com/VisualBasic/SHGetSetSetting-SHELLFLAGSTATESHELLSTATE/ 'http://msdn.microsoft.com/en-us/library/bb762200(VS.85).aspx 'http://msdn.microsoft.com/en-us/library/bb759788(VS.85).aspx Option Explicit Private Declare Sub SHGetSetSettings Lib "shell32" _ ( ByRef lpSS As Byte , ByVal dwMask As Long , ByVal bSet As Long ) Const SSF_STARTPANELON = &H200000 Public Function IsXpMenuStyleOn () As Long