【问题标题】:unable to type into username box in website无法在网站的用户名框中输入
【发布时间】:2019-04-23 16:02:09
【问题描述】:

有一个网站,我已经登录。我无法在登录表单的输入框中输入内容。

我试图获取带有标签名称“输入”的关联对象,但我无法检索它。

Dim ie As InternetExplorerMedium
Dim HTML As HTMLDocument
Dim HTML1, HTML2 As HTMLDocument

URL = "xxxx"
Set ie = New InternetExplorerMedium
ie.Visible = True
ie.navigate URL
Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy: DoEvents: Loop
Set HTML = ie.document
Set HTML1 = HTML.getElementById("_id0")

Debug.Print HTML.getElementByTagName()   '-----------------------------------------Not able to get the tag name
Call HTML1.getElementById("logon:").setAttribute("value", "username")    '---------Neither able to update the username & password too

这是页面的检查元素

我应该可以填写用户名和密码

【问题讨论】:

  • 尝试使用完整 ID“_id0:Logon:CMS:row”的 getElementByID
  • 感谢您调查我的请求。同样的问题再次出现。运行时错误 91 对象变量或未设置块变量。
  • 将结果分配给 Range 并使用 .Find() 设置范围。如果什么也没找到,那么 Range() 将是 Nothing。见链接:stackoverflow.com/questions/52504282/…

标签: excel vba


【解决方案1】:

VBA 运行时错误“91”:对象变量或未设置块变量 Internet Explorer 控件

尝试这样的操作,等到元素可用后再单击它。我使用了 HTMLGeneric 元素,因为我不知道你在处理什么类型的元素。

Dim element As HTMLGenericElement

Do
    Set element = HTMLdoc.all("eomSearchMain:advOrderSearch")
    DoEvents
Loop While element Is Nothing
element.Click
'IE busy And readyState wait here
'Document.readyState wait here

Do
    Set element = HTMLdoc.getElementById("frmOrderListing:lOrderListing:0:optxtOrderNumberActionFocusLink")
    DoEvents
Loop While element Is Nothing
element.Click
'IE busy And readyState wait here
'Document.readyState wait here

信用:link

【讨论】:

    猜你喜欢
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多