Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test server side validation in AngularJS applications

I'm developing a Spring + AngularJS 1.x application. For test automation, I'm thinking to use a functional testing tool like Selenium.

Client side form validation can be easily tested using the tool. But I was wondering how to test server side validation. If AngularJS had some setting, using which client side validation could be disabled, then my 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 that double the effort, but also I 'll have to simulate using CORS, CSRF etc., which might not be a great reality-check.

Like to hear recommendations.

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

like image 219
Sanjay Avatar asked Jul 23 '26 08:07

Sanjay


1 Answers

yes you can disable client side validation with some hacking methods like so :

first you need to use JavascriptExecutor and write a function to remove required attribute from your element(s)

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

after running this code your client side validation will disabled , and all validations are coming from server side .

like image 99
Hasan Daghash Avatar answered Jul 24 '26 21:07

Hasan Daghash