如何使用 VBScript 仅使用 class 名称来识别隐藏字段

How to identify hidden field using only class name using VBScript

我正在尝试使用 VBScript 自动化 SharePoint 表单,因为我没有在计算机上安装任何软件的权限。

目前只有一个字段,默认是textarea。它将不可见,单击它时其 class 名称会更改 :(,预计 class 没有其他字段可以识别它。

我尝试使用 class 名称访问它,但 VBScript 找不到它, classname 有一些空格,所以我正在对它进行 elemenating。下面是代码。

For Each elem In IE.Document.getElementsByTagName("div")
    Dim r, s
    Set r = New RegExp
    r.Global  = True
    r.Pattern = "^\s+|\s+$"
    id = r.Replace(id, "")
    s  = r.Replace(elem.getAttribute("class"), "")

    If s = id Then
        WScript.Echo "found class"
        WScript.Sleep 1000
        WshShell.SendKeys "found"
        s.value = "found"
        elem.value = "found"
        Exit For
    End If
Next

我什至试过下面的代码,但无法执行操作,显示回显消息但未执行点击或数据输入操作。

AllObjects = IE.Document.all.length
 for i=0 to AllObjects
    If  Trim(IE.Document.all(i).getAttribute("class")) = "nicEdit-main" Then
        IE.Document.all(i).Click
        IE.Document.all(i) = "found"
        WScript.Echo i, IE.Document.all(i).getAttribute("class")
        Exit For
    End If
Next

好吧,这很令人困惑,我之前试过这个,但它不起作用,但现在它起作用了,只需使用 focus 方法就可以了

IE.Document.all(i).focus

WsShell.SendKeys "text"

享受:D