首页 文章

QTP / UFT - 包括在SendKeys功能中选择所有文本

提问于
浏览
0

所以我有这个发送键功能:

码:

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

但我想要做的是在此函数中包含首先选择 WebEdit 字段中的文本然后输入数据的方法 .

目前,我所做的是:

码:

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

基本上我想要做的是将上面的内容组合成一个执行select all text并插入所需文本的语句 .

1 回答

  • 2

    简单地说,只需在sendkeys函数中添加一行:

    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
    

相关问题