0

こんにちは、お時間をいただきありがとうございます。

VBscript を使用して特定のサイトへのログインを自動化しようとしています。私のコードはうまく機能します...ある程度までは。スクリプトを実行すると、IE が開き、ユーザー名とパスワードの両方が入力され、送信されます。問題は、資格情報が送信された後、ユーザー名やパスワードが正しくないというエラーが表示されることです。ユーザー名とパスワードの両方が実際には 100% 正しいことを私は知っています。

犯人を突き止めたと確信していますが、対応するためにコードを修正する方法がわかりません。firebug でログイン画面をよく見ると、ドメインがユーザー名に追加されていることがわかりました。私のコードにはこれが反映されていないため、送信後にユーザー名/パスワードのエラーが発生します。

これが私のコードです...そして私のコードの下には、firebugを使用してWebサイトから取得されたJavaScriptがあります:

On Error Resume Next 

Const PAGE_LOADED = 4

Set objIE = CreateObject("InternetExplorer.Application")

Call objIE.Navigate("https://snvacaid-bwxsp01.megapathvoice.com/Login/")

objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : 

Loop

objIE.Document.loginForm.EnteredUserID.Value = "username"

objIE.Document.all.Password.Value = "password"

If Err.Number <> 0 Then

    msgbox "Error: " & err.Description

End If

Call objIE.Document.all.loginForm.submit

Set objIE = Nothing

ウェブサイトからの JavaScript:

function submitForm() {
    //append domain to the userId if it is available and not

    //already contained in the userId

    var userId = document.loginForm.EnteredUserID.value;

    var domain = document.loginForm.domain.value;

    document.loginForm.UserID.value = userId;

    if ((userId.indexOf("@") == -1) && (domain != "")){
        document.loginForm.UserID.value = userId + "@" + domain;
    }

    document.loginForm.submit();
}
4

1 に答える 1

0

私自身の質問に答えたことをすべて知らせるのに時間がかかり申し訳ありません。ただし、以下は私が思いついた解決策であり、機能します。すべての返信ありがとうございます。

On Error Resume Next 

Const PAGE_LOADED = 4

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objIE = CreateObject("InternetExplorer.Application")

Call objIE.Navigate("https://snvacaid-bwxsp01.megapathvoice.com/Login/")

objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep (100) 

Loop

objIE.Document.loginForm.UserID.Value = "username"

objIE.Document.all.Password.Value = "password"

If Err.Number <> 0 Then

msgbox "Error: " & err.Description

End If



Call objIE.Document.all.loginForm.submit
于 2013-10-30T09:10:53.623 に答える