I'm attempting to turn javascript off when using PhantomJs with GhostDriver, I have tried various ways of doing this such as:
val capabilities = DesiredCapabilities.phantomjs()
capabilities.setCapability("phantomjs.page.settings.javascriptEnabled", false)
Driver.webDriver = new PhantomJSDriver(capabilities)
However when I look at the logs when running my tests I see the following:
[INFO - 2015-01-19T15:40:05.041Z] Session [707184e0-9ff1-11e4-97ec-615db725aa4d] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":false,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.8 Safari/534.34","webSecurityEnabled":true}
[INFO - 2015-01-19T15:40:05.041Z] Session [707184e0-9ff1-11e4-97ec-615db725aa4d] - page.customHeaders: - {}
[INFO - 2015-01-19T15:40:05.041Z] Session [707184e0-9ff1-11e4-97ec-615db725aa4d] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.8","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
As you can see where I have highlighted the page settings have changed but the Session.negotiatedCapabilities settings have not changed, therefore Javascript has not been turned off.
How would I change this setting?
Thanks,
William Smith