Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18120 Posts in 4741 Topics- by 31743 Members - Latest Member: suuraj
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: COPY and PASTE method of Mercury.Device Replay/WScript is not working!!    (Read 268 times)
DEVENDRA SHARMA
Active User
**
Offline Offline

Posts: 85



« on: February 11, 2010, 11:50:29 PM »

Hello Friends - When I am trying to COPY the Text from the Web Page and try to PASTE it on Notepad. I am using the following code snippet for the same but it does not Paste the data on the notepad.
Please share your views on the same.

Find the attached source code of the Web Page.


Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").Highlight
Set Obj_Table=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123")

TopX=Obj_Table.GetRoProperty("abs_x")
'Msgbox TopX
TopY=Obj_Table.GetRoProperty("abs_y")
'Msgbox TopY
BottomX=Obj_Table.GetRoProperty("x")+Obj_Table.GetRoProperty("width")
'Msgbox BottomX
BottomY=Obj_Table.GetRoProperty("y")+Obj_Table.GetRoProperty("hieght")
'Msgbox BottomY

Set Obj_dReplay=CreateObject ("Mercury.DeviceReplay")

Obj_dReplay.MouseMove TopX, TopY
Obj_dReplay.MouseDown TopX, TopY, 0
Obj_dReplay.MouseMove BottomX, BottomY
Obj_dReplay.MouseUp BottomX, BottomY, 0


Set Obj_Shell=CreateObject ("WScript.Shell")
Obj_Shell.SendKeys ("^c")

'--- Looping until notepad is activated
Do
bActivate = Obj_Shell.AppActivate("Notepad")
If Not bActivate Then
bExec = Obj_Shell.Run("notepad.exe")
If bExec = 0 Then Wait 1
End If
Loop Until bActivate

Obj_Shell.SendKeys ("^v")
Set Obj_dReplay=Nothing
Set Obj_Shell=Nothing


Will appreciate your revert on the same.


Regards,
Devendra Sharma
Logged

'Knowledge of our own limitations is the key to success'
Rajeev Gupta
User
*
Offline Offline

Posts: 17


« Reply #1 on: February 12, 2010, 03:00:12 AM »

Use Mercury.Clipboard to retrive latest copied data from RAM
Set cb = CreateObject("Mercury.Clipboard")
Logged
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #2 on: February 12, 2010, 03:01:08 AM »

Hi Sharma,
        Try this, I have written the code as per the HTML you attached in your post.

Code
GeSHi (qtp):
Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").Highlight

Set Obj_Table=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123")

Set oFirstChild=Description.Create



oFirstChild("micclass").Value="WebElement"

oFirstChild("outertext").Value="Heading 1"





TopX=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").ChildObjects(oFirstChild)(0).getRoproperty("abs_x")+2



TopY=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").ChildObjects(oFirstChild)(0).getRoproperty("abs_y")+4



Set Obj_dReplay=CreateObject ("Mercury.DeviceReplay")

Obj_dReplay.MouseMove TopX, TopY

Obj_dReplay.MouseDown TopX, TopY, 0

Obj_dReplay.MouseMove TopX+Obj_Table.GetRoProperty("Width"), TopY+Obj_Table.GetRoProperty("Height")



Obj_dReplay.MouseUp TopX+Obj_Table.GetRoProperty("Width"), TopY+Obj_Table.GetRoProperty("Height"),0







Set Obj_Shell=CreateObject ("WScript.Shell")

Obj_Shell.SendKeys ("^c")



'--- Looping until notepad is activated

Do

bActivate = Obj_Shell.AppActivate("Notepad")

If Not bActivate Then

bExec = Obj_Shell.Run("notepad.exe")

If bExec = 0 Then Wait 1

End If

Loop Until bActivate



Obj_Shell.SendKeys ("^v")

Set Obj_dReplay=Nothing

Set Obj_Shell=Nothing

 
Created by GeSHI 1.0.7.20
Logged
Rajeev Gupta
User
*
Offline Offline

Posts: 17


« Reply #3 on: February 12, 2010, 03:02:07 AM »

ClipboardData = trim( cb.GetText)
Logged
Anshoo Arora
Advanced User
*****
Offline Offline

Posts: 835



WWW
« Reply #4 on: February 15, 2010, 10:15:36 AM »

Hi Devendra,

Any particular reason why you would like to do this through DeviceReplay?
Logged

Best Regards,

Anshoo Arora
AdvancedQTP Forums Moderator

http://relevantcodes.com - My Blog
DEVENDRA SHARMA
Active User
**
Offline Offline

Posts: 85



« Reply #5 on: February 16, 2010, 06:18:08 AM »

Hello Anshoo-No specif reason to copy the data through Device Replay, I just want to explore how we can copy the data through Device Replay as this functionality is supported by the Device Replay itself and it is not working in this scenario so I just want to understand the underlying issue.


Regards,
Devendra Sharma
Logged

'Knowledge of our own limitations is the key to success'
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #6 on: February 16, 2010, 06:36:05 AM »

Hi Sharma,
      Have you tried the code which I provided you before?

Thanks,
Asiq
Logged
DEVENDRA SHARMA
Active User
**
Offline Offline

Posts: 85



« Reply #7 on: February 16, 2010, 07:48:46 AM »

Hell Asiq- Please accept my Apology for delay in response.
I am appreciate your effort and I hope will work but due to unavailability of QTP, I did not get a chance to visit your code once I will recover my QTP then I will try and update you accordingly.



Regards,
Devendra Sharma

Logged

'Knowledge of our own limitations is the key to success'
DEVENDRA SHARMA
Active User
**
Offline Offline

Posts: 85



« Reply #8 on: March 03, 2010, 01:57:24 PM »

Hello-Asiq...Thanks a lot!!! Your above code snippet is working fine.

I need 2 clearifications on the same.

1. Why we are adding 2 in TopX & 4 in TopY in the below stmt. Although this code is working fine without this addition.

TopX=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").ChildObjects(oFirstChild)(0).getRoproperty("abs_x")+2
TopY=Browser("creationtime:=0").Page("micclass:=Page").WebTable("html tag:=TABLE", "html id:=dev123").ChildObjects(oFirstChild)(0).getRoproperty("abs_y")+4

2. What is wrong with my approach as you are putting the Mouse Move on "Heading1" column and I am putting the Mouse Move on the Web Table for the same?

Looking forward for your input.

Regards,
Devendra Sharma
Logged

'Knowledge of our own limitations is the key to success'
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #9 on: March 04, 2010, 04:21:53 AM »

Hi Sharma,
      
Quote
1. Why we are adding 2 in TopX & 4 in TopY in the below stmt. Although this code is working fine without this addition.

When I worked with this code, it was not working without this addition. Can you try your code with different resolution? If it is working fine, then leave as it is.

Quote
2. What is wrong with my approach as you are putting the Mouse Move on "Heading1" column and I am putting the Mouse Move on the Web Table for the same?

In your code you are taking x and y from webtable. The problem is: when you position the mouse pointer with webtable cooridnates, mouse pointer is not changed. So I have taken x and y from webtable's first child (I.e. row1, col1), now the mouse pointer is changed into selection cursor. You can also try this manually, you will see the difference.
Logged
DEVENDRA SHARMA
Active User
**
Offline Offline

Posts: 85



« Reply #10 on: March 04, 2010, 04:36:04 AM »

Thanks Asiq!!!
Logged

'Knowledge of our own limitations is the key to success'
Pages: [1]   Go Up
Print
Jump to: