通过使用powershell启动IE来停用加载项(用于自动化测试)

时间:2010-10-28 14:08:57

标签: windows internet-explorer powershell automated-tests add-on

我为自动化测试编写了一个脚本。我希望IE运行时没有附加组件。如果在它开始之后设置它就没关系,但重要的是我可以使用IE。 (我必须抓住它进行测试)。

我想用以下PowerShell脚本启动IE:

$ie = new-object -comobject InternetExplorer.Application -property @{navigate2=$testURL; visible = $true}

目前我使用的是不太好/干净的选择。我打开一个空IE并创建一个空的com对象...自己看:

$a = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -name ProgramFilesDir 
$b = $a.ProgramFilesDir + "\Internet Explorer\iexplore.exe" 
& $b about:blank -extoff    #start IE without extensions 

$app = new-object -com shell.application   #create empty comobject  
Start-Sleep 2  
$ie = $app.windows() | where {$_.Type -eq "HTML-Dokument" -and $_.LocationURL -match "about:blank"}  
#$app allocate to $ie

如何停用此行上的加载项: $ ie = new-object -comobject InternetExplorer.Application ... ,还是有其他替代方案可用于我的目的?

感谢

0 个答案:

没有答案
相关问题