ファイルを sharepoint ライブラリにアップロードしようとしましたが、コードが ajax 応答を待っているかどうかを正しく検出できません。これを行う適切な方法は何ですか?
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
function wait4IE($ie=$global:ie){
while ($ie.busy -or $ie.readystate -lt 4){start-sleep -milliseconds 200}
}
$global:ie=new-object -com "internetexplorer.application"
$ie.visible=$true
[Microsoft.VisualBasic.Interaction]::AppActivate("internet explorer")
# open EDM
$ie.navigate("https://xxx.sharepoint.com/sites/site1/Forms/AllItems.aspx")
wait4IE
# click on the button to display the form
$ie.Document.getElementById("QCB1_Button2").click()
wait4IE
残りのコードは実行されますが、アップロード フォームはまだ表示されていません。フォームの表示を待つ方法は?
私もこれを試しました(アップロードフォームのボタンが見つからなくなるまで待つ必要があります)が、決して終了しません...
while( $ie.document.getElementById("ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_InputFile") -eq $null){
echo "waiting ..."
wait4IE
}
更新:私は問題を見つけたと思います:フォームはiframeで開いています:
<iframe id="DlgFrame0be35d71-22cb-47bd-bbf0-44c97db61fd6" class="ms-dlgFrame" src="https://.../Upload.aspx?List={45085FA0-3AE3-4410-88AD-3E80A218FC0C}&RootFolder=&IsDlg=1" frameborder="0" style="width: 592px; height: 335px;"></iframe>
しかし今、良いフレーム番号を取得するにはどうすればよいですか?
PS>($ie.Document.frames.Item(4).document.body.getElementsbytagname("input") |?{$_.type -eq 'file'}).id
ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_InputFile
さらに、getElementsByTagName でフレーム コンテンツにアクセスできるようですが、getElementById ではアクセスできません ....?私はまだ理由を理解していません.:
PS>$ie.Document.frames.Item(4).document.body.getElementById('ctl00_PlaceHolderMain_UploadDocumentSection_ctl05_InputFile
')
Échec lors de l'appel de la méthode, car [System.__ComObject] ne contient pas de méthode nommée « getElementById ».
Au caractère Ligne:1 : 1
+ $ie.Document.frames.Item(4).document.body.getElementById('ctl00_PlaceHolderMain_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation : (getElementById:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound