从密码字段获取文本

huangapple go评论58阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月10日 06:38:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75405181.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定