2

I have been unit testing angular forms validation using Jasmine and Karma. Now I want to use protractor and karma for the same thing. To test if the inputs are valid or not (maxlength, required, etc).

Is it possible in protractor, since it is used for end to end testing?

Thanks,

1 Answer 1

2

No, I don't think checking the validity of forms is possible using Protractor. You can only validate what you see on screen. For example if the developer has added an warning/alert message if the form is not valid. You have to make the invalid scenarios and test what is expected for the end user to see on the screen.

In Protractor you get the DOM elements, not the angular models.

Sign up to request clarification or add additional context in comments.

3 Comments

So, you mean I can check with PROTRACTOR if an error appears on the screen? I mean an error the developer has put there when something is invalid. For example: "This field is required". Can I test if this message appears when it should using protractor?
@Tester: Of course, just fill out the form manually and leave some required fields blank, then do you see an error on screen? may be on submit? Then see how can you grab that element uniquely.. protractortest.org/#/api?view=ElementFinder.prototype.$ this could help. Then do the the same steps by your protractor script and validate if you get that element or not. This way, you have automated the test.
Well then thats it! This means yess I can test form validation, or closed. I can test if aerrors appear on form validation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.