aditya verma
asked on
Log into website using powershell
I want to log into a website using a username and password, so I copied the following code and executed. In result the webpage is opening but its not logging into the webpage and getting the following error.
Any suggestions?
Any suggestions?
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.navigate("url")
while($ie.ReadyState -ne 4) {start-sleep -m 500}
$ie.Document.getElementById("ctl00_username").value = "abcdef"
$ie.Document.getElementById("ctl00_password").value = "123456"
$ie.Document.getElementById("ctl00_login").click()
start-sleep 20
$ie.Document.body | Out-File -FilePath C:\Users\averm\Documents\adi\test\web123.txt
Exception from HRESULT: 0x80020101
At line:7 char:1
+ $ie.Document.getElementById("ctl00_usernamerequiredvalidator").value ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Exception from HRESULT: 0x80020101
At line:8 char:1
+ $ie.Document.getElementById("ctl00_passwordrequiredvalidator").value ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Exception from HRESULT: 0x80020101
At line:9 char:1
+ $ie.Document.getElementById("ctl00_login").click()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
I agree with Bill, also when the web page opens up, do you see the username field having the value that you provided in your script - for e.g. abcdef ?
ASKER
Here is my URL: https://sfe-uat.epway.com
I'm giving exact values for user name Element ID = ctl00_username
for Password Element ID = ctl00_password
for login id = ctl00_login
username and password are not correct credentials. I just gave as example.
I'm giving exact values for user name Element ID = ctl00_username
for Password Element ID = ctl00_password
for login id = ctl00_login
username and password are not correct credentials. I just gave as example.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Code Worked for me. Thanks a lot.
Great, glad that helped.
»bp
»bp
ASKER
Now actually I need some more help with this code. I'm logging into the page but i need to download a statement. The attached images shows you what to download.
Step1: In home page under "Reports" i need to select "Aging"
Step2: In "Aging" page i need to go to "Aging Group" and select "Direct Energy Aging" and select "Export". so that it will download my statement.
The following 4 images may help you to get some information. Please help me to find the solution.
1.png
2.png
3.png
4.png
Step1: In home page under "Reports" i need to select "Aging"
Step2: In "Aging" page i need to go to "Aging Group" and select "Direct Energy Aging" and select "Export". so that it will download my statement.
The following 4 images may help you to get some information. Please help me to find the solution.
1.png
2.png
3.png
4.png
Since your original question was solved by this comment, you might want to mark that as a Solution to this question, and then open a new question for the additional help you need navigating the follow on pages. Some new experts may find the new question better that way...
»bp
»bp
»bp