我使用 Excel VBA 从 AngularJS 应用程序中进行网页抓取。我尝试使用类似 ie.Document.getElementsByTagName("button")(15).Value = "112233"
在文本输入中输入值
我也尝试过 - ie.Document.parentWindow.execScript "document.getElementsByTagName('button')[15].Value = '112233';
它们都不起作用。我搜索了一些其他发布的问题,但问题仍然存在。该元素是:
<input whole-number="" type="text" maxlength="20" class="......" ng-model="pList.pNumber" bs-typeahead="typeahead_ProjectNumber" placeholder="enter a value" data-provide="typeahead" ng-change="reduceScrollMax()">
最佳答案
我找到了问题的解决方案:
angular.element(document.getElementByTagName('input')[15]).scope().pList.pNumber = '112233';
其次是
angular.element(document.getElementByTagName('input')[15]).scope().$apply();
或angular.element(document.getElementByTagName('input')[15]).scope().$digest();
包括 ie.Document.parentWindow.execScript "..."
中提到的上述内容使用 VBA 运行它。
关于javascript - 使用 javascript/VBA 以编程方式输入 angularjs 文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39752893/