locked
Powershell- Can't set Textarea. RRS feed

  • Question

  • I'm looking at a web page with a text area:

    <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.



    Friday, July 10, 2020 2:33 PM

Answers

  • Thanks for providing your inputs.

    Have resolved this issue by calling focus() before setting value of the textarea.

    Thanks, Cheers.

    • Marked as answer by DivyaMah Tuesday, July 14, 2020 1:20 PM
    Tuesday, July 14, 2020 1:20 PM

All replies

  • It will be next to impossible for us to check/verify if we can't login ourselves.

    Look at your textareavalue variable to see what it actually looks like and it if actually is the type of object you think you have and it has a value property.

    Friday, July 10, 2020 2:49 PM
  • If I will show you the output returned by 

    $textareavalue variable.

    Would it be possible for you to understand to a some extend & help me out.

    Friday, July 10, 2020 3:10 PM
  • Maybe, but the error message tells you right there that Value isn't a property so there's something else you're missing.

    The variable could be empty or doesn't contain the type of object you think it does.

    Saturday, July 11, 2020 1:41 PM
  • If I will show you the output returned by 

    $textareavalue variable.

    Would it be possible for you to understand to a some extend & help me out.

    That wouldn't be helpful.

    Use "$textarea | Get-Member" and "$textarea.GetType()".

    "Value" is probably an inherited method (i.e. you won't find it in this object's data) and not a property name.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Saturday, July 11, 2020 3:08 PM
  • Thanks for providing your inputs.

    Have resolved this issue by calling focus() before setting value of the textarea.

    Thanks, Cheers.

    • Marked as answer by DivyaMah Tuesday, July 14, 2020 1:20 PM
    Tuesday, July 14, 2020 1:20 PM