Justin
Justin

Reputation: 1438

How to test placeholder text on input field in Protractor?

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?

Upvotes: 8

Views: 8460

Answers (2)

krishnarajanr
krishnarajanr

Reputation: 696

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.

Upvotes: 2

Brine
Brine

Reputation: 3731

As mentioned in the Protractor FAQ, try element.getAttribute('value')

Upvotes: 6

Related Questions