从PowerShell打开Internet Explorer时出现问题
Issue opening Internet Explorer from PowerShell
我正在编写一个PowerShell脚本,它可以从intranet网站上进行大量屏幕抓取。我无法访问,也无法修改该网站的源代码。
该脚本从打开Internet Explorer开始(由于公司政策,需要IE11),然后浏览几个页面,并根据从各个页面中收集的信息执行操作。一切似乎都很好。
在一个特定的页面上,脚本必须在2个输入框中输入信息以生成超链接列表,然后使用click()选择其中一个超链接。超链接是一个指向void(0)的href,然后是onclick中的JavaScript函数。
<td align="left" class="wGNodeStyle">
<a href="javascript:void(0)" class="workgroupStyle" onclick="openWgMgmtWindow(2)">
JavaScript函数打开一个新窗口,并向这个新窗口提交一些用户信息。
function openWgMgmtWindow(selIndex) {
document.getElementsByName("workgroupSo.groupId")[0].value = eval('document.all.wgGroupId'+selIndex+'.innerHTML');
document.getElementsByName("workgroupSo.primaryGroupId")[0].value = eval('document.all.wgGroupPrimary'+selIndex+'.innerHTML');
document.getElementsByName("actionString")[0].value = "Search";
var w = window.open("", document.forms['formManageWG'].target,winProps);
w.focus();
document.forms['formManageWG'].submit();
return false;
}
问题是:
如果我在PowerShell之外打开Internet Explorer,通过单击其图标,甚至直接运行可执行文件,导航到有问题的页面并单击超链接,将打开一个新窗口并显示预期屏幕。即使我像刚才描述的那样打开Internet Explorer并执行脚本,省略IE的脚本启动,只找到IE对象,一切都会正常工作,并且会像上面一样打开一个新窗口。
# & "$env:programfiles'Internet Explorer'iexplore.exe" 'https://www.ehpas.com'
$objEhpas = New-Object -comObject Shell.Application
do {
Start-Sleep -Milliseconds 500
$ieEhpas = @($objEhpas.windows() | ? {$_.locationName -like '*EHPAS Home Page*' })[0]
} while ($ieEhpas -eq $null)
但是,如果我让脚本启动Internet Explorer,当我单击超链接页面时,将打开一个新的空白窗口,然后在具有超链接页面的选项卡旁边也会打开一个全新的选项卡,其中包含新窗口中应包含的内容。我在流程中找不到新的选项卡,所以我无法控制它。
问题是,直接打开InternetExplorer和通过程序打开它有什么区别?我如何使程序化版本的行为与直接版本相同?
我为帖子太长而道歉。
我终于找到了问题的答案。显然,这是InternetExplorer11中的一个错误,不会被修复。
https://connect.microsoft.com/IE/feedback/details/812072/ie-11-window-open-issue
该问题对我来说是存在的,因为我正在管理模式下运行PowerShell。以"我自己"的身份运行PowerShell解决了如何打开IE的问题,但也带来了一些其他挑战。然而,我应该能够通过编码走出去。
- Backbone.js路由器和Internet Explorer重定向问题
- 如果调试器关闭,Internet Explorer将出现运行代码问题
- 使用大括号的 Internet Explorer 上的 AngularJS 数据绑定问题
- Internet Explorer 中的 JavaScript 方向更改问题
- 在internet explorer上使用jquery时出现问题
- KnockoutJS:Internet Explorer中的多选问题
- 在Internet Explorer 11中使用SoundCloud进行身份验证时出现问题
- Highcharts 4.0.4 Internet Explorer上的导出问题
- 这个Javascript出了什么问题"Internet Explorer无法打开Internet站点-操作中止
- 在Internet Explorer 8中的Iframe中创建TinyMCE时出现问题
- 禁用 Internet Explorer 8 jQuery 中的缓存问题
- Internet Explorer Ajax 调用,缓存响应问题
- Internet Explorer 9 和 JavaScript 变量范围问题
- Internet Explorer 中的 Json 响应问题
- 当单击 shift + 鼠标左键单击时,Internet Explorer 浏览器问题 ,文本会自动突出显示
- BHO Internet Explorer插件-脚本注入问题
- 使用Internet Explorer更新Kendo DropDownList时出现问题
- 从PowerShell打开Internet Explorer时出现问题
- HTML5拖放;Internet Explorer中的删除问题(无法访问dataTransfer属性)
- 长轮询-Internet Explorer 8的问题