I have following HTML for 'User Name' which I would like to set in my script.
<input id="user_name" value="" autocomplete="off" type="text" name="user_name">
Here is the powershell code I have written to achieve it :
$ie = new-object -com InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate("https://abcdnow.com/navpage.do")
while ($ie.Busy) {start-sleep -s 3}
$ie.Document.getElementByID("user_name").value = "Username"
$ie.Document.getElementByID("user_password").value = "Password"
This is the Error I receive :
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At D:\servicenow.ps1:7 char:1
+ $ie.Document.getElementByID("user_name").value = "Username"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
It's because your controls are inside a frame. You have to do this:
$ie.Document.getElementById("gsft_main").contentWindow.document.getElementByID("user_name").value = "UserName"