0

So I have this send keys function:

Code:

Public Function sendKeys(Obj, strParam)
    Wait(1)
    Obj.Click
    Dim shell
    Set shell = CreateObject("WScript.Shell")
    shell.SendKeys strParam
    set shell = Nothing
    Wait(2)
End Function

But what I would like to do is include in this function a way to first select the text in the WebEdit field then enter the data.

At the moment what I do is this:

Code:

call sendKeys( Browser("openurl:= ").Page("url:= ").WebElement("xpath:= "), "^a")
call sendKeys( Browser("openurl:= ").Page("url:= ").WebElement("xpath:= "), "text")

So essentially what I would like to do is combine the above into one statement that performs the select all text and inserts the required text.

Eitel Dagnin
  • 959
  • 4
  • 24
  • 61
  • 1
    If the field is a `WebEdit`, just use the `.Set` method of the `webedit` which will do essentially what you require in that it will clear the value and set it to whatever you want it to be – Dave Jul 04 '18 at 00:35

1 Answers1

2

Simply, just add a line to your sendkeys function :

Public Function sendKeys(Obj, strParam)
    Wait(1)
    Obj.Click
    Dim shell
    Set shell = CreateObject("WScript.Shell")
    shell.SendKeys "^a" 'New line
    shell.SendKeys strParam
    set shell = Nothing
    Wait(2) 
End Function