jenkins - Check if a Powershell script has frozen using a separate script -
so i'm preforming automated testing using powershell in jenkins. i'm testing web application must fill out forms, retrieve values, etc.
it fine web app contains pop messages appear every , then, causes main script freeze until manually closed in application. below link stack overflow thread similar problem.
powershell website automation: javascript popup box freeze
i followed advice of first answer. created separate powershell script executing , can tell if there pop window present (as have own process ids, if there more 1 iexplore process id present must popup) , uses sendkeys close it.
main script example:
#start application start c:\users\webapp #start monitor script start-process powershell.exe -argumentlist "-file c:\users\monitor.ps1" #get app object $app = new-object -comobject shell.application $clientselectpage = $app.windows() | {$_.locationurl -like "http:webapp.aspx"} #input value cause popup message $memnumberinput = $clientselectpage.document.getelementbyid("memnum") $memnumberinput.select() $memnumberinput.value = "22" $findbtn.click()
it @ point script freeze (as pop window appears tell me info abotu client i've inserted) if popup can seen process, monitor code close it.
example of monitor
$i = 0 while($i -eq 0) { #check process running under webapps name $mainprocid = get-process | {$_.mainwindowtitle -like "*webapp*" } | select -expand id $mainprocid.count $integer = [int]$mainprocid #if there 1 process, no action if( $mainprocid.count -eq 1) { echo "no popup" } else { if($integer -eq '0') { #if there no processes close script $i = 1 echo "close process" } else #if there 2 processes 1 must pop, send 'enter' app { echo "pop up!" $title = get-process |where {$_.mainwindowtitle -like "*webapp*"} #code sendkeys 'enter' application close popup follows here } } }
however, whatever reason, pop ups cannot found processes , monitor script useless them. these few , far between, figured best way monitor script check , see if main script has frozen amount of time. if so, can use sendkeys method other popups.
is there way me check , see if main script has frozen, monitor script? understand pass parameter main script every , then, let monitor script know still active, seems messy way of doing it, , alternative method preferable.
both scripts saved .ps1 files.
Comments
Post a Comment