I have a jenkins job that should run a power shell script which opens a webpage, clicks on a button that downloads excel sheet.
This is my PS script.
cls
$global:url="http://www.testURL.com"
$global:XLSDoc=""
Function get-ExcelReport {
$myDocPath=[environment]::getfolderpath("mydocuments")
$ie=new-object -com internetexplorer.application
"$global:url"
$ie.navigate($global:url)
$ie.visible=$true
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$Link=$ie.Document.getElementByID("saveExcel") | where-object {$_.type -eq "button"}
$Link.click()
$global:XLSDoc = Get-ChildItem $myDocPath
| Where-Object {$_.name -like "resyncreport*"} | foreach-object -process { $_.FullName }
"XLSDOC $global:XLSDoc"
}
get-ExcelReport
when i run this from powershell console it works, but when i run it as a jenkins job it is not working.
any ideas ?
thanks in advance.
Jenkins when running as Windows service runs up against some issues while launching the GUI based applications. That was tripping me when I was trying to launch a WPF application via script. Try to run Jenkins via command line. If it is the same issue then it should work.