How to Test Server Side Validation in AngularJS Applications

I am developing a Spring + AngularJS 1.x application. For test automation I am thinking of using a functional testing tool like Selenium.

Client side validation can be easily tested with the tool. But I was wondering how to check server side validation. If AngularJS had some kind of setting that could turn off client-side validation, then the same test scripts could be used for server-side testing. Otherwise, I think I'll have to write server test scripts using a separate API testing tool. Not only will this double the effort, but I will be simulating CORS, CSRF, etc., which may not be very realistic.

How to hear recommendations.

(Note: in AngularJS, if we submit the form, even if client-side errors are displayed, AngularJS does not fill in the fields)

+3


source to share


1 answer


yes, you can turn off client side validation with some hack:

first you need to use JavascriptExecutor

and write a function to remove the attribute required

from your element (s)



  ((JavascriptExecutor)driver).executeScript("document.getElementById("city").required = false;");

      

after running this code your client side validation will be disabled and all validations come from the server side.

+1


source







All Articles