2017-02-22 210 views
0

我需要登錄一個網站。 每次我使用VBA進行身份驗證時,在點擊事件之後,它會說密碼不正確。用VBA登錄網站即

如果我使用VBA插入憑據,並且手動取消用戶名的一個字母,我重寫它,如果手動取消密碼的一個字母,我重寫它,在用VBA發送單擊事件後作品。

這是什麼原因? Shound我使用kinda keypress事件插入憑證?這是正確的語法?

感謝

請參見下面的HTML代碼,以及我在VBA寫

Set ie = CreateObject("InternetExplorer.Application") 
    With ie 
     .Visible = True 
     .navigate "sss.html" 

    Do Until .ReadyState = 4 
     DoEvents 
    Loop 
    .Document.all.Item("login").Value = "username" 
    .Document.all.Item("password").Value = "password" 
Set elems = ie.Document.getElementsByTagName("button") 
For Each e In elems 
    If (e.innerHTML = "Confirm") Then 
     e.Click 
     Exit For 
    End If 
Next e 

<input type="text" ng-model="login" class="form-control ng-pristine ng-valid ng-touched" id="login" placeholder="Enter login (email)"> 
<input type="password" ng-model="password" class="form-control ng-pristine ng-valid ng-touched" id="password" placeholder="Password"> 
<button class="btn btn-default" ng-click="authenticate()" notranslate="">Confirm</button> 
+0

我猜想有一些事件處理程序附加到輸入是造成這個問題 - 它期望用戶輸入,而你沒有輸入......沒有一個網址,雖然很難提出有用的建議。嘗試了 –

+0

。不起作用。給我一個錯誤,說該方法或財產不支持的對象 – nwtn

+0

URL在這裏http://my.nuvap.com/home.html#/login – nwtn

回答

0

這個網站要你真正輸入您的用戶名/密碼,實際上按「確認」按鈕,你可以模仿它與SendKeys

所以不是設置value和循環爲按鈕元件的,使用此代碼:

.Document.all.Item("login").focus 
SendKeys "username", True 
.Document.all.Item("password").focus 
SendKeys "password", True 
SendKeys "{TAB}", True 
SendKeys "~", True 

希望這有助於。