Search code examples
hp-uft

Copy text and paste in UFT


I would like to copy a text from a webpage and paste it in another field on the same web page.

Here is what I've tried so far without success

This is my code:

Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$Tabs").GetROProperty + micCtrlDwn + "a" + micCtrlUp
Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$Tabs").GetROProperty + micCtrlDwn + "c" + micCtrlUp
Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$TabsCPe_3").Click
Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$TabsCPe_3").GetROProperty + micCtrlDwn + "v" + micCtrlUp

It clicks on the field i need it to copy the text from but does not select all the text and copy it to the defined destination.

Object properties for feild1 after entering text manually

feild1 object spy


Solution

  • Why don't you just fetch the value from field1, store it in a variable and set that value to field2 as shown below:

    Dim strValue
    'fetch the value from field1 and store it in a variable
    strValue = Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$Tabs").getRoProperty("value")
    
    'set that value to field2
    Browser("Candidate").Page("Candidate").WebEdit("ctl00$Main$TabsCPe_3").set strValue