Micro Focus QTP (UFT) Forums
Drag and Drop Annoying QTP Behavior - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Drag and Drop Annoying QTP Behavior (/Thread-Drag-and-Drop-Annoying-QTP-Behavior)



Drag and Drop Annoying QTP Behavior - ShaneP - 07-02-2014

Hello all! So, I'm trying to drag and drop elements on a page. The script seems to work ONLY if the elements are visible on the screen. QTP does find the element but when it drags, the page automatically scrolls to the top, and it can't scroll back down to where it needs to drop the dragged element.

So my questions are:
Is there a way to scroll to the specified element and LOCK the scrolling?
Is there a way to stop QTP from jumping to the top of the page when it clicks on something?

Here is some code that I'm using. Ignore the numbers in SS_DragConstantSum, they will become variables later once I'm done testing. Also, both of these elements are not visible until I manually scroll down on the page.

QTP 11.53 P1
Chrome 30
Windows 7

Thank you Smile

Code:
'SS_DragFlags
'@Description Drag flags to a specified section in the field
'@Dcoumentation Drag the flag <Name> to the ruler
Public Sub SS_DragFlags(obj, Name)
    If obj.WebElement("class:=flag_container", "innerhtml:="&Name).Exist(5) Then
        obj.WebElement("class:=flag_container", "innerhtml:="&Name).Drag
        obj.WebElement("class:=ruler").Drop
    Else
        Reporter.ReportEvent micFail, "Flag: "&Name&" | Not found on page", ""
    End If
End Sub

RegisterUserFunc "Page" , "SS_DragFlags" , "SS_DragFlags"
'--------------------------------------------------------------------------------------------



'SS_DragCardSort
'@Description Drag cards to a specified section in the field
'@Documentation
Public Sub SS_DragCardSort(obj, CardIndex, DropZoneName)
    If obj.Image("class:=ui-draggable", "index:="&CardIndex).Exist(5) Then
        obj.Image("class:=ui-draggable", "index:="&CardIndex).Drag
        obj.WebElement("class:=OptionRow", "outertext:="&DropZoneName&".*").Drop
    Else
        Reporter.ReportEvent micFail, "Card Image: "&CardIndex&" or DropZone: "&DropZoneName&" | Not found on page", ""
    End If
End Sub

RegisterUserFunc "Page" , "SS_DragCardSort" , "SS_DragCardSort"
'--------------------------------------------------------------------------------------------

An example with CardSort on what happens if I want to put the card into Choice C:

Code centers the screen perfectly, but once the drag is executed...
[Image: 4Lx0y0Z.jpg?1]

It scrolls to the top of the page where it can't drop it in Choice C. This only happens when using drag, drop.
[Image: zHF8T99.jpg?1]

I want to avoid using coordinates as much as possible as they can obviously not be reliable depending on the contents of the page.


RE: Drag and Drop Annoying QTP Behavior - Nj_Acc - 08-21-2015

I am facing the same issue, were you able to resolve it? Please do share information related to this.
Version - UFT12.02
Browser - Google Chrome

Summary of Issue - there is a tree panel where all values can be uniquely identified as webelements. As there are many values there is a scrollbar, I am able to drag the values which are at the top but if I try to drag the values for which scrolling is required UFT behaves weirdly i.e. it comes down automatically to drag the required webelemt and then automatically moves to the top! And also throws an error: "Invalid procedure call or argument".

Only object.Drag and object.drop work for me.
I have tried things like mercury Device replay (MouseDown, MouseUp, DragandDrop)

Tried insight recording, visual relation identifier, does not help.