We're adding some translations to our applications and I need to make a few protractor tests that grab placeholder text and check that it's being properly loaded.
How do I check the text of the placeholder on an input field using protractor?
getAttribute('placeholder'). then(function(element){ expect(element). toEqual('<expected placeholder txt>'); }); This works for me.
The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.
As mentioned in the Protractor FAQ, try element.getAttribute('value')
element(by.model('<modelName>')).getAttribute('placeholder').then(function(element){
expect(element).toEqual('<expected placeholder txt>');
});
This works for me. I used it with model
, you can use it with any element you are testing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With