尝试使用VBA填充Web表单,无法解决元素问题 [英] Trying to fill web form with VBA, can´t address element

查看:209
本文介绍了尝试使用VBA填充Web表单,无法解决元素问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用工作簿中的数据在IE中填写一个Web表单但是我在查找文本框时遇到了问题,因为它似乎缺少名称。

I am trying to fill out a web form in IE with data from a workbook but I am having trouble addressing the text box since it seems to lack a name.

该网站是登录后面所以没有链接,抱歉。但该元素表现为

The site is behind a login so no link, sorry. But the element presents itself as

<input type="text" placeholder="  Søg på brugernavn, referencenummer, eller e-mail" ng-model="filterSearch.search" ng-change="filterOnSearch()" ng-model-options="{ debounce: 500 }" class="ng-pristine ng-valid ng-empty ng-touched">

用chrome检查时。

when inspecting it in chrome.

我试过了

ie.document.getelementsbyclassname("ng-pristine ng-valid ng-empty ng-touched").Value = "11"

但是VBA引发了一个运行时错误'438':对象没有支持这个属性或方法。

but VBA throws me a run-time error '438': Object doesn't support this property or method.

有什么建议吗?

推荐答案

它可能听起来令人困惑,但无论何时你试图按类名拉取元素,你都需要使用

It may sound confusing but anytime you are trying to pull an element by classname you need to use the

.item(0)

之后你会使用类似的东西

after that you would use something similar to

ie.document.getelementsbyclassname("ng-pristine ng-valid ng-empty ng-touched").item(0).Value = "11"

这假设您正在尝试填写具有上述类的输入框,并且该元素是其类中的唯一1或第一个。

This is assuming that you are trying to fill out an input box that has the class above and that the element is the only 1 in its class or the first one.

如果是这样的话它不起作用它可能不是该类中的第一个元素,然后你可能需要做第(1)项或第(2)项等。

In the event that it does not work it may not be the first element in that class and then you may need to do item(1) or item(2) etc.

这篇关于尝试使用VBA填充Web表单,无法解决元素问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆