InternetExplorer Com对象,getElementById,getElementsByName和getElementsByTagName

时间:2010-12-27 12:40:36

标签: internet-explorer powershell powershell-v2.0 comobject

我想用PowerShell创建一个webtest。 目前,当我创建新的日历条目时,我遇到了SharePoint文本框的问题。 Field的属性是:

现在你可以看到,我没有可以使用的固定ID。

可以搜索“标题”一词并获取ID吗?

(title = titel因为它是德国人;-))

以下代码无效。

$ie2.Document.getElementById( "*ctl00$TextField").value = "test"
$ie2.Document.getElementByName( "*ctl00$TextField").value = "test"
$ie2.Document.getElementByTagName( "Titel").value = "test"

Internet Explorer中的源代码:

<td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>Titel<span class="ms-formvalidation" title="Dies ist ein Pflichtfeld." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="Titel"
             FieldInternalName="Title"
             FieldType="SPFieldText"
          -->
            <span dir="none">
        <input name="ctl00$m$g_27855e01_08c1_498d_b130_0b761c472fbd$ctl00$ctl05$ctl00$ctl00$ctl00$ctl04$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_m_g_27855e01_08c1_498d_b130_0b761c472fbd_ctl00_ctl05_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField" title="Titel" class="ms-long ms-spellcheck-true" /><br />
    </span>

1 个答案:

答案 0 :(得分:1)

你应该考虑使用WATIN from PowerShell,WATIN会让你的生活更轻松。