I encountered a problem while trying automated login on a website using PowerShell IE Com Object. My script could pass text values into both email and password forms, but they seem unrecognised by the site. As such, the login button is unclickable, preventing login process. There are prompts to provide credentials despite the script having done so as shown below:
Forms input passed by script not recognised
When I edit the texts in the forms directly from the IE window (added random characters), the texts became recognised and the login button would then become lit and clickable. As the credentials I used are random, the site returned an invalid message.
Forms input recognised after direct edit
May I request for help on why the text are not recognised despite the script having passed them into the forms. Any advice or workaround is very much appreciated.
The website is https://juice-shop.herokuapp.com/#/login
My script is as shown below:
$url = "https://juice-shop.herokuapp.com/#/login"
$email = "[email protected]" #random email
$password = "password" #random password
$ie = New-Object -ComObject 'InternetExplorer.Application'
$ie.Visible = $true
$ie.Navigate($url)
#Wait for browser to finish
while($ie.Busy){Start-Sleep -Seconds 2}
#email form input
$emailForm = $ie.Document.IHTMLDocument3_getElementById('email')
$emailForm.click()
$emailForm.value = $email
#password form input
$passwordForm = $ie.Document.IHTMLDocument3_getElementById('password')
$passwordForm.click()
$passwordForm.value = $password
#click login button
$submitButton = $ie.Document.IHTMLDocument3_getElementById('loginButton')
$submitButton.click()