之前寫過 Nightwatch.js 的 debug 血淚史,前一陣子有個需求是想用 Nightwatch.js來做各瀏覽器的速度測試,因此期望每次開啟的 session 都是個乾淨的 session (不要有 cache, cookie 等等…)
在這紀錄一下,如何設定各 driver 每次開啟都是全新的 session
前情提要: 本篇使用 [email protected] ((3.5.0以上可能會有不同的問題…
以下為 nightwatch 設定檔(nightwatch.json) 的 test_settings
部分
- IE8 以上
"ie": { "desiredCapabilities": { "browserName" : "internet explorer", "javascriptEnabled": true, "acceptSslCerts": true, "ie.ensureCleanSession": true } }
- Safari
"safari": { "desiredCapabilities" : { "browserName" : "safari", "javascriptEnabled" : true, "acceptSslCerts" : true, "ensureCleanSession": true, "cleanSession": true } }
- Chrome
"chrome" : { "desiredCapabilities": { "browserName": "chrome", "chromeOptions": { "args": ["--incognito"] } } }
- Firefox
"firefox" : { "desiredCapabilities": { "browserName": "firefox", "javascriptEnabled": true, "acceptSslCerts": true, "marionette": true } }
參考資料:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
Leave a Reply