错误未知错误:丢失或无效' entry.level'在执行Nigthwatch.js时

时间:2018-03-15 17:26:05

标签: linux selenium ubuntu selenium-chromedriver nightwatch.js

您好我正试图在我的stagin环境中运行基本测试。相同的通用测试适用于Google,但在我的暂存环境中无效。这是测试:

browser.url('https://google.com')
.execute(function () {

    alert('this works');

});

当我将此测试运行到我的个人环境中时,我收到此错误:

Running:  Test Project Play
INFO Request: POST /wd/hub/session 
 - data:  {"desiredCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","chromeOptions":{"args":["ignore-certificate-errors","disable-web-security","ignore-certificate-errors"]},"name":"Test Project Play"}} 
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":245}
INFO Response 200 POST /wd/hub/session (1592ms) { status: 0,
  sessionId: '104d0fe3600f4da9b8deddf0adc06b42',
  value: 
   { applicationCacheEnabled: false,
     rotatable: false,
     mobileEmulationEnabled: false,
     networkConnectionEnabled: false,
     chrome: 
      { chromedriverVersion: '2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5)',
        userDataDir: '/tmp/.org.chromium.Chromium.UszN4c' },
     takesHeapSnapshot: true,
     pageLoadStrategy: 'normal',
     databaseEnabled: false,
     handlesAlerts: true,
     hasTouchScreen: false,
     version: '64.0.3282.186',
     platform: 'Linux',
     browserConnectionEnabled: false,
     nativeEvents: true,
     acceptSslCerts: true,
     locationContextEnabled: true,
     webStorageEnabled: true,
     browserName: 'chrome',
     takesScreenshot: true,
     javascriptEnabled: true,
     cssSelectorsEnabled: true,
     unexpectedAlertBehaviour: '',
     'webdriver.remote.sessionid': '104d0fe3600f4da9b8deddf0adc06b42' } }
INFO Got sessionId from selenium 104d0fe3600f4da9b8deddf0adc06b42
INFO Request: POST /wd/hub/session/104d0fe3600f4da9b8deddf0adc06b42/url 
 - data:  {"url":"https://app.bespotful.com/player/6940"} 
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":47}
INFO Response 200 POST /wd/hub/session/104d0fe3600f4da9b8deddf0adc06b42/url (3064ms) { sessionId: '104d0fe3600f4da9b8deddf0adc06b42',
  status: 13,
  value: { message: 'unknown error: cannot determine loading status\nfrom unknown error: missing or invalid \'entry.level\'\n  (Session info: chrome=64.0.3282.186)\n  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.13.0-36-generic x86_64)' } }
LOG     → Completed command url (3068 ms)
INFO Request: POST /wd/hub/session/104d0fe3600f4da9b8deddf0adc06b42/execute 
 - data:  {"script":"var passedArgs = Array.prototype.slice.call(arguments,0); return function () {\n\n            alert('this works');\n\n        }.apply(window, passedArgs);","args":[]} 
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":177}
ERROR Response 500 POST /wd/hub/session/104d0fe3600f4da9b8deddf0adc06b42/execute (296ms) { value: 
   { message: 'java.net.ConnectException: Connection refused (Connection refused)',
     error: 'unknown error' },
  status: 13 }
LOG     → Completed command execute (298 ms)
INFO FINISHED
No assertions ran.

我怀疑它是cors或ssl问题但无法确认。

感谢任何线索。如果我找到答案,我会在这里发布。

1 个答案:

答案 0 :(得分:1)

错误说明了一切:

INFO Response 200 POST /wd/hub/session/104d0fe3600f4da9b8deddf0adc06b42/url (3064ms) { sessionId: '104d0fe3600f4da9b8deddf0adc06b42',
  status: 13,
  value: { message: 'unknown error: cannot determine loading status\nfrom unknown error: missing or invalid \'entry.level\'\n  (Session info: chrome=64.0.3282.186)\n  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.13.0-36-generic x86_64)' } }

从您的错误堆栈跟踪中可以清楚地看到 Chrome浏览器会话未初始化。

您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:

  • 您正在使用 chromedriver = 2.29
  • chromedriver=2.29的发行说明明确提及以下内容:
  

支持 Chrome v56-58

  • 您正在使用 chrome = 64.0
  • chromedriver=2.35的发行说明明确提及以下内容:
  

支持 Chrome v62-64

因此 ChromeDriver v2.29 Chrome浏览器v64.0

之间明显不匹配

解决方案

  • ChromeDriver 升级到最近的级别chromedriver=2.36
  • ChromeBrowser 升级到最近的级别 chrome = 65.x
  • 通过 IDE 清理您的项目工作区仅使用所需的依赖项重建项目
  • 使用CCleaner工具清除执行测试套件之前和之后的所有操作系统杂务。
  • 如果您的基本 ChromeBrowser 版本太旧,请通过Revo Uninstaller将其卸载并安装最近的GA和已发布的 ChromeBrowser 版本。
  • 执行@Test