How to disable Javascript when using Selenium?

前端 未结 16 721
星月不相逢
星月不相逢 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:29

    This is the simple answer, for python at least.

    from selenium import webdriver
    
    profile = webdriver.FirefoxProfile()
    profile.set_preference("javascript.enabled", False);
    driver = webdriver.Firefox(profile)
    

提交回复
热议问题