2013-01-08 83 views
4

我發現這個腳本在線,我編輯了大部分。VBScript啓動網站登錄

它能夠輸入用戶名和密碼,但無法點擊登錄。

請幫我修復 這裏是登錄論壇。

http://desistream.tv/en/index.shtml 

這裏是腳本目前它在IE瀏覽器,但我需要改變它在谷歌瀏覽器打開。

WScript.Quit Main 

Function Main 
    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") 
    IE.Visible = True 
    IE.Navigate "http://desistream.tv/en/index.shtml" 
    Wait IE 
    With IE.Document 
    .getElementByID("login_username").value = "myusername" 
    .getElementByID("login_password").value = "mypassword" 
    .getElementByID("form").submit 
    End With 
End Function 

Sub Wait(IE) 
    Do 
    WScript.Sleep 500 
    Loop While IE.ReadyState < 4 And IE.Busy 
    Do 
    WScript.Sleep 500 
    Loop While IE.ReadyState < 4 And IE.Busy 
End Sub 

Sub IE_OnQuit 
    On Error Resume Next 
    WScript.StdErr.WriteLine "IE closed before script finished." 
    WScript.Quit 
End Sub 

回答

3

這裏是......

Call Main 

Function Main 
    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") 
    IE.Visible = True 
    IE.Navigate "http://desistream.tv/en/index.shtml" 
    Wait IE 
    With IE.Document 
     .getElementByID("username").value = "myusername" 
     .getElementByID("pass").value = "mypassword" 
     .getElementsByName("frmLogin")(0).Submit 
    End With 
End Function 

Sub Wait(IE) 
    Do 
    WScript.Sleep 500 
    Loop While IE.ReadyState < 4 And IE.Busy 
End Sub 
+0

謝謝,如果帳戶已經登錄,我該如何添加條件?因爲它提示錯誤。 – Mowgli

+1

很高興看到我不會忘記一切,因爲我最後一次網頁腳本是在10年前:) 網站規則不允許在一個主題中有多個問題,所以如果你願意的話可以打開新的主題,並且可能會得到更好的回覆,但我的簡短回覆是 - 僅在登錄時檢查該頁面上可用的html元素,並檢查是否存在該元素,並僅在需要時纔開始登錄。 –

+0

至於在谷歌瀏覽器中這樣做,你不能沒有自動擴展。看到這個線程[鏈接](http://stackoverflow.com/questions/87911/tool-framework-for-automated-web-app-testing-in-google-chrome-browser),或只是谷歌「谷歌鉻瀏覽器自動化」。 –

1

如果你看一下頁面的源代碼,你會看到實際<form>標籤被稱爲frmLogin,不login

+0

非常感謝,我看着DIV ID論壇上,不能形成名字,非常感謝。 – Mowgli

+0

我有問題,如果帳戶已經登錄,我該如何使它不提示錯誤?謝謝 – Mowgli