0

I'm looking at a web page with a textarea:

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

I want to set value of the textaea, however in doing so I am getting error :-

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

Could anyone please help me in setting value of textarea.

I am using the below code for setting value of textarea.

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

$textareavalue.value='Test'

Below is my script :-

$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()

Thanks in Advance.

  • Please show how you converted your XML to a PowerShell object. For me it initially looked a bit too much like Javascript. – Alex_P Jul 10 '20 at 13:07
  • Looks like your `$textareavalue` variable did not get anything. You don't show enough of the HTML to help you unfortunately. Besides, `getElementsByTagName` can return an array of textarea elements, not just the one.. – Theo Jul 10 '20 at 13:15
  • Hi, have updated my script code. Please help – Divya Mahajan Jul 10 '20 at 13:23
  • @Theo $textareavalue do have the value as in my form there is only one textarea so that is being returned by getElementsByTagName – Divya Mahajan Jul 10 '20 at 13:24

1 Answers1

0

I have resolved this issue on my own by adding focus() before setting value of the textarea.