英文:
Get text from password field
问题
I am trying to get text from password field, as I need it to pass the test case.
Currently I am trying to do it with this
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.Text, user.Password);
However when it gets to the assert, it fails as it compares the user.Password
value and returned value, which consists of only asterisks "*".
Tried it with GetAttribute("value")
, but got the same result
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.GetAttribute("value"), user.Password);
For now I changed the assert so that it would compare lengths of value
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.Text.Length, user.Password.Length);
Is there any way to get the text instead of asterisks, or should I just use the length?
英文:
I am trying to get text from password field, as I need it to pass the test case.
Currently I am trying to do it with this
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.Text, user.Password);
However when it gets to the assert, it fails as it compares the user.Password
value and returned value, which consists of only asterisks "*"
Tried it with GetAttrubute("value")
, but got the same result
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.GetAttribute("value"), user.Password);
For now I changed the assert so that it would compare lengths of value
_passwordInput.SendKeys(user.Password);
Assert.Equals(_passwordInput.Text.Length, user.Password.Length);
Is there any way to get the text instead of asterisk, or should I just use the length?
答案1
得分: 0
通常,如果在用户界面中至少可见,并且在检查器和页面源中也可用,你可以获取控件的值。
对于编辑字段,你可以使用以下方式获取值:
_passwordInput.GetAttribute("Value.Value")
如果字段的值被***隐藏,你应该首先通过按特殊图标来使其可见(如果可用),然后获取值。
英文:
Usually, you can get control value if it is at least visible in UI, and it also should be available in Inspector and Page source.
For Edit fields you can get value using:
_passwordInput.GetAttribute("Value.Value")
If the field value is hidden by *** you should first make it visible by pressing a special icon if it is available and then get the value.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论