2016-09-20 105 views
1

我想設置Jenkins與Web應用程序進行交互並返回結果,但首先我要在網頁上對其進行測試。如何知道網頁是否已在Jenkins中打開?

我只是想與Random.org進行交互,按下按鈕返回一個值,但我甚至無法打開網頁本身。

我試過下面的代碼:

#Start-Process 
$ie = New-Object -com InternetExplorer.Application 

$ie.Navigate("https://www.random.org") 
$ie.visible = $true 
sleep 30 

if($ie.visible -eq $true) 
    { 
echo "Random.org opened" 
    } 
else 
{ 
echo "Random.org did not open" 
} 

但這總是返回回聲"Random.org did not open"。我已經意識到,現在可能$ie.visible -eq $true不是檢查詹金斯的最佳方法,因爲它在後臺運行並且無法看到。有另一種方法可以檢查網頁是否打開嗎?

回答

0

只需查詢您InternetExplorer.Application COM對象的busy屬性:

#Start-Process 
$ie = New-Object -com InternetExplorer.Application 

$ie.Navigate("https://www.random.org") 
while($ie.busy){Start-Sleep 1} 
相關問題