Powershell IE Automation-无法为文本区域设置值

Powershell IE Automation- Can't Set value for Text area

我正在查看带有文本区域的网页:

<textarea aria-label="Add comment" class="form-control" cols="0" maxlength="100000" name="text" rows="0" tabindex="0" aria-required="true"></textarea>

我想设置 textaea 的值,但是在这样做时出现错误:-

Error Details - Exception setting "value": "The property 'value' cannot be found on this object. Verify that the property exists and can be set.

谁能帮我设置textarea的值。

我正在使用下面的代码来设置文本区域的值。

 $AddCommentBtn = $ie.document.getElementsByTagName("section") | where {$_.className -eq "modal fade modal-addnote in"}
    $textareavalue=$AddCommentBtn.getElementsByTagName('textarea')

$textareavalue.value='Test'

下面是我的脚本:-

$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible

$username=""

$password=""

$ie.Navigate("to some web-page")

While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}

$usernamefield = $ie.document.getElementByID('Username')
$usernamefield.value = "$username"

$passwordfield = $ie.document.getElementByID('Password')
$passwordfield.value = "$password"

$Link = $ie.document.getElementByID('submit-signin-local')
$Link.click()

While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}

$ie.Navigate("to some form")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 10;}

$description = 'Test Description'
$descriptionfield = $ie.document.getElementByID('description')
$descriptionfield.value = "$description"

$AddCommentBtn = $ie.document.getElementsByTagName("section") | where {$_.className -eq "modal fade modal-addnote in"}
$textareavalue=$AddCommentBtn.getElementsByTagName('textarea')
$textareavalue.value='Test'

#InsertButton
$Link = $ie.document.getElementByID('InsertButton')
$Link.click()
$ie.Quit()

提前致谢。

我已经通过在设置文本区域的值之前添加 focus() 自行解决了这个问题。