I am writing a test which takes into consideration whether a select has been pre-populated.
it('should select field if it was not selected', function() {
var usersField = element(by.id('users'));
usersField.getAttribute('value').then(function(value) {
console.log('value = ', value);
if(!value) {
//select first option if not pre-populated
usersField.all(by.tagName('option')).get(0).click();
}
});
});
I have tried usersField.getText() but that just lists all the options from the dropdown so it doesn't help. My console log returns ? object:null ?
for the value. Why is that? How can I simply check the value of the selected option if it's there and if not, select the first option?