我試圖測試依賴localStorage的應用程序。當我手動與瀏覽器交互時,一切正常。但是,在nightwatch.js
而不是所需的字符串時,請求localStorage時收到空響應。這適用於Chrome和Firefox。在nightwatch.js中啓用localStorage/webStorage
我已經嘗試過讓localStore在夜巡JSON通過分配"webStorageEnabled" : true
在desiredCapabilities
這樣的:
{
"src_folders" : ["tests/functional/tests"],
"output_folder" : "tests/functional/reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "/Library/WebDevelopment/selenium-server/selenium-server-standalone-2.45.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/usr/local/lib/node_modules/chromedriver/lib/chromedriver/chromedriver",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"webStorageEnabled" : true,
"databaseEnabled" : true,
"applicationCacheEnabled" : true,
"nativeEvents" : true,
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
是localStorage
應該使用nightwatch.js
何時工作?
這讓我走上了正軌,儘管在代碼中它在瀏覽器中打印出來而不是控制檯。我想通過result.value如何返回它。謝謝! –