<div class="hidden-fields hidden" style="display: block; overflow: visible;">
**<input type="password" id="current-password" placeholder="Enter Your Current Password">**
<div class="pass-guide-group">
**<input type="password" placeholder="New Password" id="new-password">**
<span class="pass-guide">Password must contain at least 8 characters and three of the following: upper case, lower case, number, and symbols.</span>
</div>
**<input type="password" placeholder="Confirm New Password" id="confirm-password">**
</div>
<div class="submit-controls" style="display: block; overflow: visible;">
*<input type="button" class="btn btn-inline btn-save-inline" id="savePassword" value="Save">*
<a href="#" class="edit-form btn-b btn-cancel-inline btn-inline" id="cancelPassword">Cancel</a>
******这是我的代码*******
_driver.FindElement(By.XPath("//form[@id='frmChangeUserPass']/div/input")).SendKeys("abc123");
_driver.FindElement(By.Id("new-password")).SendKeys("abc1231");
_driver.FindElement(By.Id("confirm-password")).SendKeys("abc123");
_driver.FindElement(By.Id("savePassword")).Click();
//等待&#34;密码成功更改&#34;要显示的消息
WaitElementVisbileById("cardholder-settings-success");
vaidationMessage = _driver.FindElement(By.Id("cardholder-settings-success")).Text;
我正在使用带有c#绑定的selenium WebDriver来自动更改密码功能。
我无法与输入元素进行交互,在上面的代码中是粗体。但是斜体字可以互动。
答案 0 :(得分:-1)
如果问题确实与input
元素进行了互动,则无效,但无论如何,您发送给new-password
和confirm-password
的值都不同:
_driver.FindElement(By.Id("new-password")).SendKeys("abc1231");
_driver.FindElement(By.Id("confirm-password")).SendKeys("abc123");