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?
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.