小编The*_*ere的帖子

使用VBA时,Form.Submit不会通过

我有一个网页,我正在从中提取数据.除了单击一个图像元素然后提交一个表单并创建一个带有数据的弹出窗口,我可以用VBA完成一切.

image元素中的一个属性称为"productguid",其字符串值为=

"a12-545".

在使用鼠标单击图像元素之前,表单的HTML代码如下所示.

<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
  <input type="hidden" name="ProductGuid" value="">
</form>
Run Code Online (Sandbox Code Playgroud)

这是我用鼠标手动点击后的HTML代码:

<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
  <input type="hidden" name="ProductGuid" value="a12-545">
</form>
Run Code Online (Sandbox Code Playgroud)

基于此,我假设image元素的productguid值在提交之前传递给表单.这是我的VBA代码如下所示:

'Change the input element value
ie.Document.getElementById("GetProductQuantitiesForAccessibleBranches").all.item(0).value = "a12-545"

'Submit the form
ie.Document.getElementyId("GetProductQuantitiesForAccessibleBranches").Submit
Run Code Online (Sandbox Code Playgroud)

根据Locals窗口,所有Javascript事件都是Null.这两行代码都运行没有任何错误,但网页不会更新.我在这里错过了什么吗?

我也试过用.Click方法单击图像元素,但这也没有做任何事情.

该网页受密码保护,因此我无法公开发布该网址.

更新:

这是标记中的HTML,通常手动单击,然后提交表单.也许这里有什么我可以使用的东西?

<img alt="View Quantities At Other Locations" src="/WebOrder/Images/CheckQtys.gif" 
title="View Quantities At Other Locations" class="popup" 
popupdirection="upperleft" popupwidth="380" 
popupcontent="#ProductQuantitiesForAccessibleBranches" 
onbeforepopupcreate="onBeforePopupCreate_GetProductQuantitiesForAccessibleBranches(this)" 
popupajaxformid="GetProductQuantitiesForAccessibleBranches" 
onbeforepopupajaxpost="onBeforePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)" 
oncompletepopupajaxpost="onCompletePopupAjaxPost_GetProductQuantitiesForAccessibleBranches(this)" 
productguid="a12-545" 
displayitem="33902" 
brandguid="00000000-0000-0000-0000-000000000000" 
brandname="" brandsku="">
Run Code Online (Sandbox Code Playgroud)

html javascript vba dom browser-automation

5
推荐指数
1
解决办法
697
查看次数

标签 统计

browser-automation ×1

dom ×1

html ×1

javascript ×1

vba ×1