如何使用Powershell在网站上的文本框中插入文本

时间:2017-06-14 00:43:16

标签: html powershell

我试图将文字插入网站的文本框中,但我似乎做错了,因为我在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;
&#13;
&#13;

非常感谢您提供的任何建议或指示。

0 个答案:

没有答案