如何让Nightwatch.js在Internet Explorer上运行testing

我正在尝试在Internet Explorer,Chrome和Firefox上运行一些基本的夜间testing。 虽然我可以得到铬和Firefox的工作,我不能让我的生活使Internet Explorer的工作。 我试过search这个网站,特别是find了这个答案,但是没有任何帮助。 当然,我也通过夜视文件看无济于事

这是我的nightwatch.conf.js文件:

const BINPATH = './node_modules/nightwatch/bin/'; // we use a nightwatch.conf.js file so we can include comments and helper functions module.exports = { "src_folders": ["test"],// Where you are storing your Nightwatch e2e tests "output_folder": "./reports", // reports (test outcome) output by nightwatch "selenium": { // downloaded by selenium-download module "start_process": true, // tells nightwatch to start/stop the selenium process "server_path": "./node_modules/nightwatch/bin/selenium.jar", "host": "127.0.0.1", "port": 4444, // standard selenium port "cli_args": { // chromedriver is downloaded by selenium-download (see readme) "webdriver.chrome.driver" : "./node_modules/nightwatch/bin/chromedriver", "webdriver.ie.driver": "C:/Users/[uname]/Develop/IEDriverServer.exe", "webdriver.gecko.driver": "C:/Users/[uname]/Develop/geckodriver.exe", "webdriver.firefox.profile": "" } }, "test_runner": "mocha", "test_settings": { "default": { "screenshots": { "enabled": false, "path": './screenshots' // save screenshots here }, "globals": { "waitForConditionTimeout": 5000 // sometimes internet is slow so wait. }, "desiredCapabilities": { // use Chrome as the default browser for tests "browserName": "ie" } }, "chrome": { "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true // turn off to test progressive enhancement } }, "ie": { "desiredCapabilities": { "browserName": "internet explorer", "version": "11", "selenium_port" : 4444, "selenium_host" : "localhost", "javascriptEnabled": true, "acceptSslCerts": true, "allowBlockedContent": true, "ignoreProtectedModeSettings": true } }, "firefox": { "desiredCapabilities": { "browserName": "firefox", "javascriptEnabled": true // turn off to test progressive enhancement } } } }; /** * selenium-download does exactly what it's name suggests; * downloads (or updates) the version of Selenium (& chromedriver) * on your localhost where it will be used by Nightwatch. /the following code checks for the existence of `selenium.jar` before trying to run our tests. */ require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it? if (err || !stat || stat.size < 1) { require('selenium-download').ensure(BINPATH, function(error) { if (error) throw new Error(error); // no point continuing so exit! console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH); }); } }); 

这是我从我的testing中接受的错误:

 > nightwatch --config nightwatch.conf.js Starting selenium server... started - PID: 7624 Asset Library left hand nav 1) "before all" hook 0 passing (319ms) 1 failing 1) Asset Library left hand nav "before all" hook: Connection refused! Is selenium server started? npm ERR! Windows_NT 10.0.15063 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" npm ERR! node v6.11.1 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE npm ERR! ui-centre-tests@1.0.0 start: `nightwatch --config nightwatch.conf.js` npm ERR! Exit status 10 npm ERR! npm ERR! Failed at the ui-centre-tests@1.0.0 start script 'nightwatch --config nightwatch.conf.js'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the ui-centre-tests package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! nightwatch --config nightwatch.conf.js npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs ui-centre-tests npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls ui-centre-tests npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! C:\Users\[uname]\Develop\HSBC\UICentre\npm-debug.log 

Nightwatch设置为自己启动selenium服务器,开始testing后访问localhost:4444确实已经启动。 改变浏览器到Chrome和Firefox也工作正常,它只是IE是问题所在。 我试过使用64位和32位版本的IEDriverServer,并将它们添加到我的PATH,但仍然没有。 任何帮助将非常感激!

编辑:我更新了我的package.json,以便npm开始运行nightwatch --config nightwatch.conf.js --env ie,chrome,firefox 。 有了这个,IE的一个实例现在可以打开,但实际上并没有运行testing

我终于搞定了,这里是我为了让它工作而执行的步骤

  1. 手动设置每个环境的最低安全设置,方法是转到工具> Internet选项>安全>自定义,然后自行设置单选button。
  2. 然后我设置我的nighwatch.conf.js文件使用标志--env ie,chrome,firefox这样的testing将运行在我做的所有三个套件,而不是只是默认的IE,这是如何configuration之前。 当我这样运行的时候,我已经进入了第一步:现在IE会打开,但是只会显示“这是WebDriver服务器的初始页面”,但是不会做任何事情
  3. 在testing失败之后(因为IE没有执行testing中的步骤),然后我确保安全设置被设置为在由IE驱动程序打开的浏览器的这个实例上尽可能低
  4. testing仍然不会运行,所以我最后一步是手动将辅助监视器上默认打开的IE窗口移动到主监视器上,以便在testing运行时默认打开,BOOM! 在IE中工作的testing:D

祝你好运,任何人苦苦挣扎,IE是痛苦的工作