Absent Member.. Absent Member..
Absent Member..
3828 views

Drag and Drop testing in Windows 7 - Impossible with UFT?

Jump to solution

I am using UFT 11.53, testing a custom .NET application in a Windows 7 x64 environment but have run into what seems to be a serious problem - there seems to be no way to test a simple Drag and Drop of a file from Windows File Explorer onto my application.

 

I have discovered that, running as a regular (limited) user, UFT cannot recognize the objects in the WinList object component of Windows Explorer.  So it is impossible to, for instance, do a .Select operation on a particular test file shown in the Explorer window.

 

If I run as a privileged (Administrator) user, UFT can now see the hierarchy within Windows Explorer down to the WinList object and therefore can select particular files.  So far so good, I thought.

 

But, running as Administrator, my Software Under Test (SUT) is also started (by UFT) with privileges.  However, Windows 7 does not allow Drag and Drop from a limited process onto a privileged process such as my SUT.

 

Unfortunately, it seems that Windows 7 also actively prevents starting Explorer.exe with privileges.  It always runs as limited, even when started by a privileged user or process.  So, the Explorer (opened also by UFT during the test) cannot be a source for Drag and Drop onto the SUT.  Windows 7 prevents it (cursor turns into a black slash-circle over the drop target).

 

Attempting to run UFT with privileges (to allow file selection) while starting the SUT as limited has so far been problematic; while I can get Drag and Drop to work (with analog recording only, I might add),  it causes other problems with UFT and other parts of my test break.  The UFT Help suggests as much, saying that UFT and all the test objects should be started by the same user.

 

Has anyone successfully tested Drag and Drop from Windows File Explorer in a Windows 7 environment?  How?

 

Tags (2)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. Absent Member..
Absent Member..

I developed a solution - where there's a will, there's a way.  Perhaps this will be useful to the UFT community.

 

To allow drag and drop for UFT in Windows 7, you have to change the message filters for the SUT process.  I created a library function to do this. 

 

Extern.Declare micInteger, "ChangeWindowMessageFilter", "user32.dll", "ChangeWindowMessageFilter", micUInteger, micDWord
Const WM_DROPFILES    = &H0233
Const WM_COPYDATA    = &H004A
Const MSGFLT_ADD    = 1
Const MSGFLT_REMOVE    = 2
'@Description enables drag and drop messages when process is started elevated
Public Function EnableDragNDrop7()
    ' enables drag and drop messages when process is started elevated
    ' per    http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/
    Dim status
    status = Extern.ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD)
    status = Extern.ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD)
    status = Extern.ChangeWindowMessageFilter(&H0049, MSGFLT_ADD)
    
    EnableDragNDrop7 = status
End Function

In the actual test code, it looks like this:

 

' enable drag-n-drop even if running elevated
If EnableDragNDrop7() Then
    Reporter.ReportNote("Drag and Drop successfully enabled for testing")
    Print "Drag and Drop successfully enabled for testing"
End If

 

View solution in original post

0 Likes
6 Replies
Admiral
Admiral

Hello ,

 

As per my knowledge , QTP/UFT doesn't support drag and drop of objects from different environments ( Like desktop and SUT ) .

Some objects support dra and drop when they are in single SUT. Drag and drop between two applications is not yet supported.

 

Regards ,

 

If you haven’t tried it yet, come and join us in our entitled forums at :

 http://h30499.www3.hp.com/t5/News/Support-Customer-Forums-now-available/m-p/5610181/message-uid/5610181#U5610181

HP support Engineers will be available to answer queries.

 

[If this post or any other post helps to resolve your issue or query, mark the thread as solved and give KUDOS to the author for their assistance. ]

( Posts and opinions made here are my own and do not reflect the opinions of my employer HPE in any way . )
0 Likes
Absent Member.. Absent Member..
Absent Member..

I developed a solution - where there's a will, there's a way.  Perhaps this will be useful to the UFT community.

 

To allow drag and drop for UFT in Windows 7, you have to change the message filters for the SUT process.  I created a library function to do this. 

 

Extern.Declare micInteger, "ChangeWindowMessageFilter", "user32.dll", "ChangeWindowMessageFilter", micUInteger, micDWord
Const WM_DROPFILES    = &H0233
Const WM_COPYDATA    = &H004A
Const MSGFLT_ADD    = 1
Const MSGFLT_REMOVE    = 2
'@Description enables drag and drop messages when process is started elevated
Public Function EnableDragNDrop7()
    ' enables drag and drop messages when process is started elevated
    ' per    http://helgeklein.com/blog/2010/03/how-to-enable-drag-and-drop-for-an-elevated-mfc-application-on-vistawindows-7/
    Dim status
    status = Extern.ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD)
    status = Extern.ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD)
    status = Extern.ChangeWindowMessageFilter(&H0049, MSGFLT_ADD)
    
    EnableDragNDrop7 = status
End Function

In the actual test code, it looks like this:

 

' enable drag-n-drop even if running elevated
If EnableDragNDrop7() Then
    Reporter.ReportNote("Drag and Drop successfully enabled for testing")
    Print "Drag and Drop successfully enabled for testing"
End If

 

View solution in original post

0 Likes
Absent Member.
Absent Member.
I had a similar issue, i used a combination of analog and device replay to fix the issues.
steps -
1. Ensure your application and window are open in appropriate size.
2. Record analog to select and drag (just a few pixel).
3. Use device replay to move the dragged object to your AUT.
4. Use Device replay to click and drop the object. <get abs_x and abs_y> for accuracy.

This approach is little sensitive but can be used in a controlled environment and can be made smarter to response on environment change.
Example –
Window("tests").RunAnalog "Track1" ‘’ this analog just clicks and drags the object to a few pixels or points.
wait(1)
devRep.MouseMove iXpos +10,iYpos + 10
devRep.MouseClick iXpos +10,iYpos + 10,0
Hope this helps
0 Likes
Absent Member.. Absent Member..
Absent Member..

Thanks for the post.  Your suggested techniques are basically what I am using to actually perform the Drag'n'Drop; I used analog recording.  However, without changing the permissions for inter-application communication, the analog recording didn't work, because Windows 7 blocked the operation.

 

Stan

 

0 Likes
Absent Member.
Absent Member.

Here is a subroutine as a workaround for the problem.

Aneejian
www.aneejian.com
Absent Member.. Absent Member..
Absent Member..

Thank you!   very interesting how you locate the drag item in Windows Explorer.   I used analog recording but that is sensitive to any changes in window size or directory contents.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.