1
Powershell을 사용하여 사이트에서 일부 테스트를 자동화하려고합니다. 새 탭을 여는 앵커에서 click 이벤트를 발행 할 때 문제가 발생했습니다. 새 탭에서 핸들을 가져온 다음 새 탭에서 인쇄 버튼을 클릭하여 처리를 계속해야합니다. 어떻게 Powershell을 사용하여이 작업을 수행 할 수 있습니까?powershell 새 창에서 핸들 얻기
set-executionpolicy remotesigned
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("xxxxx.com")
$ie.visible = $true
$doc = $ie.document
While ($ie.Busy) {Sleep 10}
$doc -eq $null
$tb1 = $doc.getElementByID("username")
$tb2 = $doc.getElementByID("password")
$tb1.value = "xxxxxxxxxxx"
$tb2.value = "xxxxxxxxxxx"
$btn = $ie.document.getelementsbytagname("input")|where{$_.name -eq "Submit"}
$btn.click()
$ie.navigate("xxxxx.com/admin/reports.html#")
$link = $ie.Document.getElementsByTagName('A') | where-object {$_.innerText -eq 'All Photos'}
$link.click()
<<<<<<<<<<< it's here where a new tab is open and we need to get a handle on the new page to be able to click the print button >>>>>>>>>>>
$popupHandle = $ie.openwindow.winrefs[$targetName]
$btn = $popupHandle.document.getelementsbytagname("input")|where{$_.name -eq "print"}
$btn.click()
우리는 Powershell을 (를) 처음 사용했습니다.
감사 리처드
코드를 공유 할 수 있습니까? – David
코드를 보지 않고도 쉽게 대답 할 수 있습니다. 그러나 다음 트랙을 찾을 수 있습니다. http://msdn.microsoft.com/en-us/magazine/cc163301.aspx –