How to disable Javascript when using Selenium?

前端 未结 16 723
星月不相逢
星月不相逢 2020-12-05 05:07

I am wondering how do I disable javascript when using selenium so I can test server side validation.

I found this article but I don\'t know what to really do. Like I

16条回答
  •  盖世英雄少女心
    2020-12-05 05:49

    You don't need to disable JavaScript. If you fill out your form you can use JavaScript to submit your form e.g. use runScript and window.document.forms[0].submit().

    Whenever you call submit() directly on a form, the form is submitted directly to the server, there is no onsubmit event fired, and therefore, no client-side validation. (Unless your form action is something like javascript:validateForm(), in which case your system doesn't work when JavaScript is disabled).

提交回复
热议问题