我有一個網頁,我正在從中提取數據。除了點擊一個圖像元素,然後提交一個表單並創建一個帶有數據的彈出窗口,我可以用VBA做一切正常工作。使用VBA時,Form.Submit不通過
在一個圖像元素的屬性被稱爲「productguid」,並具有一個字符串值=
「a12-545」。
表單的HTML代碼看起來像這個之前我用鼠標點擊圖像元素。
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="">
</form>
這是HTML代碼後我手動點擊它用鼠標:
<form id="GetProductQuantitiesForAccessibleBranches" action="GetProductQuantitiesForAccessibleBranches" method="post">
<input type="hidden" name="ProductGuid" value="a12-545">
</form>
基於此我假定從圖像元件的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
據當地人窗口,所有的JavaScript事件Null
。這兩行代碼無任何錯誤地運行,但網頁不會更新。我在這裏錯過了什麼嗎?
我也試過用.Click
方法點擊圖片元素,但是也沒有做任何事情。
該網頁受密碼保護,因此我無法公開發布該網址。
UPDATE:
這裏是在通常被手動地點擊,然後提交表單的標記的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="">
如果一個頁面元素的值正在改變基於一個點擊事件,我敢打賭,所有的javascript事件都不爲空。 IE對象可能由於某種原因未顯示某些事件,但深入研究該JavaScript無疑將成爲理解正在發生的事情的關鍵。通過例如自己調查頁面上的腳本/事件您最喜愛的瀏覽器的開發控制檯。我也強烈建議添加javascript和/或dom標籤來獲得這裏的一些專家。 – Mikegrann
噢,謝謝。我厭倦了使用Chrome Dev,但是我很難理解我在看什麼......如果我點擊網絡選項卡,在啓動器列中,我看到一個腳本,然後當我將它鼠標懸停時,整個列表不同的事情出現。我該怎麼處理這些信息? – TheGuyOverThere
設置值如下:'ie.Document.getElementById(「GetProductQuantitiesForAccessibleBranches」)。getElementsbyName(「ProductGuid」)(0).Value =無論什麼工作 –