How to test labels in QTP - delphi

I'm using QTP 9.5 test my application written in
Delphi. I got Delphi Add-in installed and QTP
can identify Delphi controls. Most but not all,
specially TLabel. QTP can not recognize this
control and is being ignored by Object Spy.
Any suggestion, tip, clues how to test labels ?
cheers !

Have you tried with TStaticText instead of TLabel?
They are Labels with a Window Handle (descending from TWinControl instead of TGraphicControl) which means they can get Windows messages from the outside.
I'm guessing that it's your problem. (only a guess as I don't know QTP)

It can detect controls like TSpeedButton? If not, this can be a sign that Qtp cannot detect controls that descend from TGraphicControl and therefore doesn't have a window handle.

You may be able to write your own Delphi extender for QTP to handle this. There should be a pdf in your QTP install path: C:\Program Files\HP\QuickTest Professional\help\Extensibility\DelphiExtensibility.chm and DelphiExtensibility.pdf.

If you still have to test it "as is" you probably have to go a more hard-coded way addressing the parent of those controls.
A window object in QTP through its methods allows finding a rectangular area containing the text, or clicking on a text found.
If it's an area on the screen with the big amount of labels you can dump a whole screen to the text file and go with the text file comparison. You can also normalize text retrieved before doing comparison.
This approach is less robust but you can improve it if calculating rectangles dynamically, without hard-coding points wherever possible.

Related

How to simulate touch with left mousebutton

I'm developing a Firemonkey Application wich should run on Windows with touchscreen.
Because I have no touchscreen for my development system, I can't test the behavior of some controls. For example the panning in a TListbox doesn't work with the mouse-button. It only works if ssTouch in KeyState is set.
Is there a way to simulate the touch via the mouse?
Regards,
Michael
Well, aside from the obvious answer (save up and get that touchscreen!), there are some solutions, but they might be a bit involved.
If I wanted to do this on PC, I would start by making a copy of the Firemonkey source code and including it in my project.
After checking to see that your 'local' copy of Firemonkey is compiling properly, you will have to edit this file: "FMX.Platform.Win.pas". Open this file and then search for "ssTouch".
Inside of the WM_LBUTTONDOWN handler, there must be some logic which determines whether "ssTouch" is part of the KeyState or not. Add it in yourself, and then the left button should be evaluated as a touch input.

Updates for controls in Win3.1 palette

Some people are saying that I must update the controls in Win3.1 palette (especially TFilterComboBox) with modern ones. But does Delphi provide such new controls?
I need to create a GUI (somehow similar to Windows Explorer, consisting in a DirectoryListBox, FileListBox and a FilterComboBox) where I allow the user to easily explore for files of a specific type. Since the interface is centered around this Explorer, a TOpenDialog will be like hitting the customer with a hammer in the middle of his head. I need an 'easy to use' solution.
Unfortunately Shell Controls are not stable enough to be used as replacement.
The Shell Controls that come as a demo with Delphi only have to be installed, and you'll have some nice shell controls. There is, IMO, no big need to get 3rd party components for that.
Look for ShellCtls (or similar, can't check right now) in your demos folder. That Demos folder can be accessed from the Windows Start menu for your version of Delphi.
Update
They are not in a Demos folder, it is called Samples now. They can be found in Samples\Delphi\VCL\ShellControls. Install vclshlctrls.dproj first and then dclshlctrls.dproj.
In our application we use tpShellShock which works rather well. You may need to tweak it a little for Unicode Delphi, but if I recall correctly that was pretty simple to do.
Here's what it looks like:

WM_Copy, wm_gettext and wm_keydown fail?

The problem: I need to obtain the selected text from a window in a Windows application (not my program). I am doing my work in Delphi XE and the software I am attempting to access is a kluge built over the past 15 years with C, C++, VB and who knows what else. I do not have the source code. The edit box (an RTF memo) I am attempting to read is of the class "Ter32Class". When I use wm_copy, nothing goes to the clipboard. when I use wm_gettext, nothing. When I use wm_keydown commands (to simulate Ctrl-Ins or Ctrl-C) nothing happens. Note that I can get all of these alternatives to work in wordpad, notepad, and FireFox but not this application (or OpenOffice, incidentally, but that's not the issue). The only way I have been able to programmatically obtain text from this box is to use autohotkey with the simple "send ^c" command. While it works, it is inelegant. HELP?!?
More information: Window hierarchy: Ter32Class is a child of OI_Mdi which is a child of MDIClient, which is a child of OI_Window . I am drilling down to obtain the appropriate handle as it will respond to a paste command.
I am using Delphi XE but I'd love any solution in C++ or VB if no Delphi XE gurus have the answer.
From Quick Macros Forum
One of the windows I need to talk to is of class Ter32Class which
apparently is a TE Edit Control, an editor that doesn't inherit from
the standard RichText Control
and
The published method of talking to this control is via it's DLL
so unless something has changed (post is 2006), it appears you'll need to use it's dll to get the text.
From Sub Systems (TE Edit control website)
Application Interface functions
GetTerBuffer: Retrieve Window Text
HANDLE GetTerBuffer(hWnd, size)

How to temporarily turn off "snap-to" (anything) in Delphi IDE /visual designer (D2007)

Every once in a while this drives me crazy: I want to move a control to some precise location, WITHOUT any kind of "snapping" -- snap-to-grid, snap-to-guidelines, snap-to-border, etc... and Delphi won't let me. Is there a key combination that one can use while dragging to temporarily turn off any and all "snapping"? I seem to recall it being available in D6, but can't for the life of me find a similar combination in D2007, short of going into Tools -> Options, etc... (which kind of defeats the purpose).
Drag with the Alt key down to disable snapping to the grid. Snapping to objects will remain in effect. You can use Ctrl with the arrow keys to move one pixel at a time. You can also type the desired coordinates into the Object Inspector.
In Delphi 2009 CodeGear has changed the behavior of ALT+Move to also disable the designer guide lines. But in Delphi 2007 this feature can't be turned off without an external tool.
On of those tools (and I think the only that can do this) is the DDevExtensions 1.6 IDE plugin that adds this ability to ALT+Move for Delphi 2007.

Is There a TSpinEdit for Floats in Delphi?

Is there really not a TSpinEdit control for floats in Delphi? It looks like there are third party components that supply a control that will work.
How do you implement TSpinEdit for floats? I've been creating my own with a TEDit field and a TSpinButton positioned right beside it but it seems like there should be a better way.
TJvSpinEdit is a part of the JEDI Visual Component Library.
As far as I know it has a property called ValueType which you can set to vtFloat.
As far as I know there exists no such component in Delphi.
I'm also using a component from a 3rd party library, SpTBXLib, which is very good for other things, too.
Even if there aren't, you can easily create one using two buttons and a textbox.
There is non in Delphi, but you can create your own.
I have done so for my open source project, you might check it out as a starting point for your own.
EDIT: You will also need following two file to get it working:
KomponenteSplosno.pas
RisanjeSplosno.pas

Resources