Monday, October 26, 2009

QTP Drag Drop Example

Example 1 of QTP Drag Drop - Using Google

I have used Firefox version 3.0.14 and QTP 10.0 for this very simple example.

Open a new test in QTP.

Make sure that http://www.google.com is open (in Firefox).

Write the below two lines in a new test in QTP and run it. It will drag the image logo into the search box.

Browser("name:=Google").Page("title:=Google").image("alt:=Google").drag
Browser("name:=Google").Page("title:=Google").webelement("innertext:=Advanced SearchLanguage Tools", "html tag:=CENTER").Drop 530, 150



End result of this run would be as seen below - the logo image location is copied into the search box as we dragged & dropped that logo into the search box.



Example 2 of QTP Drag Drop - Using Microsoft Outlook Webmail

For this below example I have used Microsoft Outlook 2007 and opened it in Internet Explorer 7.0 as a webmail.

Open a new test in QTP.

Make sure that Outlook (in IE) is open with a focus on Inbox.

Write the below two lines in a new test in QTP and Run it.

[the WebElement in the first line is recognizing the first email message in my inbox with innertext property. You have to change it according to your email message (which you want to drag & drop). The second line is dropping the message in to the Drafts folder.]

Browser("name:=Microsoft Outlook Web Access").Page("title:=Microsoft Outlook Web Access").Frame("name:=viewer").webelement("innertext:=Alvaro Gutshall").drag
Browser("name:=Microsoft Outlook Web Access").Page("title:=Microsoft Outlook Web Access").Frame("name:=navbar").Link("text:=Drafts").Drop

As seen below the first message will be dragged and dropped into the Drafts folder and second screenshot shows that Drafts folder now contains one message.





[You can look for complete syntax of Drag & Drop methods in QTP Guide.]