【问题标题】:How do I know if a web page has opened in Jenkins?我如何知道一个网页是否在 Jenkins 中打开了?
【发布时间】:2017-01-28 07:19:28
【问题描述】:

我想设置 Jenkins 以与 Web 应用程序交互并返回结果,但首先我要在网页上对其进行测试。

我只是想与 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 可能不是检查 jenkins 的最佳方法,因为它在后台运行并且看不到。有没有其他方法可以检查网页是否打开?

【问题讨论】:

    标签: powershell jenkins automation automated-tests


    【解决方案1】:

    只需查询InternetExplorer.Application COM 对象的busy 属性:

    #Start-Process 
    $ie = New-Object -com InternetExplorer.Application
    
    $ie.Navigate("https://www.random.org")
    while( $ie.busy){Start-Sleep 1}
    

    【讨论】:

      猜你喜欢
      • 2013-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 1970-01-01
      • 2013-02-20
      相关资源
      最近更新 更多