Just to add few points here.
First of all, you definitely need the quotes around the ng-show
value in this case:
element(by.css('[ng-show="my_error && dirty_field"]'));
This is because the value contains non-alphanumeric characters. See this related thread:
Also, I don't think you should use the dirty_field
part in your locator. This sounds like a more technical variable used in the form validation logic. I'd use the "contains" check instead to check the my_error
part only (note how I've removed the quotes in this case - the value is alphanumeric):
element(by.css('[ng-show*=my_error]'));
Also note that you can use the $
shortcut instead of element(by.css())
:
$('[ng-show*=my_error]');