I am getting following error message when i am running my powershell script
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At C:Test.ps1:17 char:1
+ $usernamefield.value = $username
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At C:Test.ps1:20 char:1
+ $passwordfield.value = $password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Method invocation failed because [System.DBNull] does not contain a method named 'click'.
At C:Test.ps1:23 char:1
+ $Link.click()
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound`
My script:
$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true # Make it visible
$usernmae="test"
$password="test1"
$ie.Navigate("https://website.com/login")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$usernamefield = $ie.document.getElementByID('ysi_email')
$usernamefield.value = $username
$passwordfield = $ie.document.getElementByID('ysi_password')
$passwordfield.value = $password
$Link = $ie.document.getElementByID('ysi_btn_login')
$Link.click()
I cant seem to understand the problem here, i have looked into other examples within stackoverflow but i still cant find the problem.
The same id works fine in another example in a python script.
Here is a screenshot
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…