2015-09-01 39 views
0

我試着登錄到網絡,這基本上是一個用戶名/密碼形式:登錄到網頁,而不提交

enter image description here

而且源代碼:

enter image description here

我的問題是:使用Excel vba我試圖使用form.submit方法,但這只是刷新頁面,所以我試圖找到並單擊按鈕,但顯然我做錯了什麼:

Sheets("Hoja1").Cells.Clear 
Set ie = New InternetExplorer 
ie.Visible = True 
ie.navigate "https://smap.komatsu.co.jp/cgi-bin/webdriver" 
'Wait until IE is done loading page 
Do While ie.READYSTATE <> READYSTATE_COMPLETE 
DoEvents 
Loop 
'show text of HTML document returned 
Set html = ie.Document 
ie.Document.forms("IDPASS").elements("user_id").Value = "inter62535" 
ie.Document.forms("IDPASS").elements("paswrd").Value = "******" 
Set boton = ie.Document.getElementsByTagName("TD") 
boton(5).Click 

有什麼aditional我不得不引用以點燃事件?

回答

0

只是爲了通知我設法解決這個問題通過調用Java函數:

Set html = ie.Document ie.Document.forms("IDPASS").elements("user_id").Value = "inter62535" ie.Document.forms("IDPASS").elements("paswrd").Value = "******" ie.Document.parentWindow.execScript "errmsg(document.IDPASS);

這是因爲提交表單的作用是返回false(見第一圖像)

關注

0

嘗試直接提交表單。

with ie.Document.forms("IDPASS") 
    .elements("user_id").Value = "inter62535" 
    .elements("paswrd").Value = "******" 
    .submit 
end with 
+0

我試過了,它只刷新頁面並清除密碼,我猜它沒有提供日誌功能的函數ñ。 –

+1

看來你將不得不深入研究並找出'errmsg()'的作用。 – Jeeped