私はPowerShellを使用してログインフォームを自動化したい:RAN後
<form method="post" class="login-form" name="loginForm" action="/Service/WebObjects/Service.woa/wo/0.15.7.3.1">
<label>Username</label>
<input maxlength="128" style="width: 240px;" type="text" name="username" />
<label>Password</label>
<input maxlength="64" style="width: 240px;" type="password" name="password" />
<input class="login-check-input" type="checkbox" name="rememberCheckBox" value="15.7.3.1.15" />
<label class="login-check-label" for="flag_stay_logged_in">Remember login</label><br/>
<noscript>
You need a JavaScript enabled browser to use this application.
</noscript>
<script language="javascript" type="text/javascript">
document.write('<div class="buttonBar"><input alt="Login" class="button" type="submit" value="Login" name="ButtonLogin" /></div>');
</script>
</form>
$ie=New-Object -comobject InternetExplorer.Application
$ie.visible=$true
$ie.ParsedHtml
$ie.Navigate("https://livetime/Service/WebObjects/Service")
while($ie.busy){Start-Sleep 1}
$ie.Document.getElementById("username").value="my username "
$ie.Document.getElementById("password").value="my password "
$ie.Document.getElementById('ButtonLogin').click()
このスクリプト私はこれらのエラーを取得:
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At line:7 char:1
+ $ie.Document.getElementById("username").value="mt username"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At line:8 char:1
+ $ie.Document.getElementById("password").value="my password "
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
私が見つけたインターネットの例では、このスクリプトがうまくいくことがわかりました。
私は確認できるはずですか(異なる/古いバージョンまたは設定)ですか?
あなたのHTMLページにいくつかの不具合がありますが、最も重要なのは、 'getElementById'をしたいのであれば、** id = **を定義するべきです。 は、私はあなたのHTMLページを簡単にするためにrecommentにちょうど:<!DOCTYPE HTML> ' \t
\t \t \t \t <フォームメソッド= "ポスト" クラス= "ログイン・フォームの" 名前=」 loginForm "> \t \t \t \t <入力MAXLENGTH =" 128" スタイル= "幅:240ピクセル;"タイプ= "テキスト" ID = "ユーザ名" 名前= "ユーザ名" /> \t \t \t \t <入力MAXLENGTH = "64" スタイル= "幅:240ピクセル;"タイプ= "パスワード" ID = "パスワード" 名前= "パスワード" /> \t \t \t ' – iRon(コメントで)上記のHTMLページは私のために動作します。 HTMLページを変更できない場合は、 'getElementsByTagName'(' input')を使用してそれに応じて列挙します。 – iRon
私はhtmlコードを変更できません。これ以上のものはページhtmlの一部ですが、ここでは「投稿による投稿」のみを示します。問題は$ ie.Document.getElementById( "username")。value = "my username"です。 $ ie.Document.getElementById ( "password")。value = "私のパスワード" $ ie.Document.getElementById( 'ButtonLogin')。click()は動作するはずのすべての例が表示されていても動作しません。私は何かが有効にされていない/インストールされていない、古いバージョンなどと思っている –