I have following HTML for 'User Name' which I would like to set in my script.
<input id="user_name" value="" autoplete="off" type="text" name="user_name">
Here is the powershell code I have written to achieve it :
$ie = new-object - InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate(".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
I have following HTML for 'User Name' which I would like to set in my script.
<input id="user_name" value="" autoplete="off" type="text" name="user_name">
Here is the powershell code I have written to achieve it :
$ie = new-object - InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate("https://abcdnow./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
Share
Improve this question
asked Feb 18, 2015 at 10:52
PowershelPowershel
6354 gold badges11 silver badges18 bronze badges
1
- Have you verified if this element exists? Because your code works for me with another address and element. – wallybh Commented Feb 18, 2015 at 11:00
1 Answer
Reset to default 1It'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"
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745110924a4611846.html
评论列表(0条)