Powershell getElementById() not working with IE11
Dear Microsoft,
I was reading the MSDN article article
Web UI Automation with Windows PowerShell. When I am testing the script of DOM manipulation I found that the getElementbyID() method could not work under IE11.
With some search, there is another StackOverflow article getElementById does not seem to work in IE10 seems to suggest the same.
Is this due to some news security restrictions imposed by the new IE? Based on the original contents of the article, can any modification be made to make the Powershell snippets work with IE11?
Bob
September 26th, 2014 8:03pm
You can not use it like u shown. Try like below
$url = "http://www.facebook.com"
$username="Your_username"
$password="Your_password"
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($url);
while ($ie.Busy -eq $true)
{
Start-Sleep -Milliseconds 1000;
}
$ie.Document.getElementById("email").value = $username
$ie.Document.getElementByID("Pass").value=$password
#$ie.Document.getElementById("signin").Click();
i tested in IE 11. Windows 2012 Sever
September 27th, 2014 2:45pm
Chen,
I tested your code also with server 2012 ie11, yet got the following error message:
Poweshell version is 4.
The IE security enhancement mode has been disabled for the current user. Is there any additonal settings needed to make this work?
Bob
September 27th, 2014 4:10pm
Let me check again bob, but ideally I dont prefer this method because this is not secured and not good practice. Try API for automation.
I will post the update in short
September 27th, 2014 4:54pm
May be not related but just give a try by enabling compatibility view in your Win 2012 browser
Strange in either way its working for me. This is definite IE settings issue.
give a try with below code
$url = "http://www.facebook.com"
$username="emailid"
$password="password"
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($url);
while ($ie.ReadyState -ne 4)
{
Start-Sleep -Milliseconds 1000;
}
$ie.Document.getElementById("email").value = $username
$ie.Document.getElementByID("Pass").value=$password
$ie.Document.getElementById("loginbutton").Click();
September 27th, 2014 5:12pm
Dear Chen,
Thanks for help.
I tried after enabling compatibility (in pic), but still see the same problem.
Do you know how I could bring this to Powershell development team's attention?
Bob
September 27th, 2014 8:38pm
This is not PowerShell issues - this is Windows IE security settings issue.
You can log this issue in
https://connect.microsoft.com/IE
September 27th, 2014 9:29pm
Hi Bob,
Any update on this issue?
Best Regards,
Anna Wang
October 10th, 2014 10:38am
I found that on Windows 10 for some reason the getElementById() method was now case sensitive and produced an error when calling the correct text, but in the wrong case.
You might want to try this.
November 5th, 2014 9:18pm
I ran into this problem today and my search for an answer brought me here.
This may not be explicitly a Powershell issue - but I noticed something while testing.
I can successfully use getElementById() on a Win7 Pro x64 w/ IE11 system using Powershell 3; BUT...
getElementById() fails if I use it on a Win7 Pro x64 w/ IE11 system using Powershell *4*.
It's discouraging that an explanation hasn't popped up in the past few months. Are people getting around this some other way?
-
Edited by
D.R.Williams
Thursday, January 15, 2015 4:39 AM
January 15th, 2015 7:39am
I just tried the same code in Windows Server 2012 IE 11and no issues identified
January 19th, 2015 9:47pm
$ie.Document.getElementById('email').value
=
$username $ie.Document.getElementByID('Pass').value=$password
#$ie.Document.getElementById('signin').Click();
What happens After the single quotes?
February 16th, 2015 2:59am