我试图将文字插入网站的文本框中,但我似乎做错了,因为我在Powershell IDE中一直收到错误。我使用的代码是:
($ie.Document.DocumentElement.getElementsByClassName('web-password-input') | Select-Object -First 1).value = 'asdf'
它在IDE中显示的错误是:
The property 'Value' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\file.ps1:53 char:5
+ ($ie.Document.DocumentElement.getElementsByClassName('web-passwor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
我在项目前面使用过这段代码并且工作正常,因为这是提交按钮而不是插入文本。
$fs = $ie.Document.DocumentElement.getElementsByClassName('right-nav button button-link last') | Select-Object -first 1
$fs.click()
我尝试定位的HTML代码是:
<web-password-input aria-invalid="{errors.password.hasErrors}" errors="{errors.password}" input-id="password" aria-described-by="error-message1" focus="{pwdFocus}" ready="{passwordComponentReady}" classes="content-input" placeholder="new password" flow="{flow}" value="{password}" strength="{strength}" percentage="{percentage}" {password-policy}="passwordPolicy">
<input class="pwd form-textbox form-textbox-text override error has-errors content-input" id="password" aria-invalid="true" aria-required="true" aria-describedby="error-message1" type="password" placeholder="new password" autocomplete="off" can-field="{value}" errors="{errors}">
&#13;
非常感谢您提供的任何建议或指示。