PowerShell的IE自动化的getElementById有多个条目 [英] powershell IE automation getElementByID with multiple entries

查看:694
本文介绍了PowerShell的IE自动化的getElementById有多个条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这仅得到第一个元素,虽然后端CGI(如PHP),可以得到所有这些在数组中。

this only gets the first of the elements, though the backend cgi (such as php) can get all these in an array.

$surl=some url
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate($surl)
$doc = $ie.Document
$element = $doc.getElementByID("some_name[]")

这仅得到第一个具有相同名称的元素。

this only gets the first of the elements with the same name.

我试图用一个脚本来填充值,但到目前为止还没有想出一个办法,以超越第一这些元素。我不控制文档渲染所以不能改变这些的命名方式。

i am trying to fill values with a script but so far have not figured out a way to go beyond the first of these elements. i do not control the document rendering so cannot change how these are named.

感谢任何想法!

推荐答案

这是HTML ID必须是唯一的!所以这就是为什么你只有一次。

An HTML ID has to be unique! So that's why you only get one.

来源: http://www.w3schools.com/tags/att_standard_id.asp

id属性指定的HTML元素一个唯一的ID(价值
  必须是在HTML文档中是唯一的)。

The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).

id属性是最常用的指向一个风格样式表,
  而由JavaScript(通过HTML DOM)来操纵的元素
  具体的ID。

The id attribute is most used to point to a style in a style sheet, and by JavaScript (via the HTML DOM) to manipulate the element with the specific id.

按照的getElementById 文件:

返回与指定值的参考第一对象
  ID或NAME属性。

Returns a reference to the first object with the specified value of the ID or NAME attribute.

使用 getElementsByClassName getElementsByName 或<一个HREF =htt​​p://msdn.microsoft.com/en-us/library/ie/ms536439%28v=vs.85%29.aspx相对=nofollow>的getElementsByTagName 来代替。

这篇关于PowerShell的IE自动化的getElementById有多个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆