Protractor: jarfile selenium-server-standalone-4.0.0-alpha-1.zip.jar无效或损坏

创建于 2019-04-24  ·  40评论  ·  资料来源: angular/protractor

当我启动webdriver-manager时出现此错误,我没有在项目中更改任何证明该错误的理由,并且我每天都在使用它一年多了。

错误:jarfile无效或损坏。/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-4.0.0-alpha-1.zip.jar


  • 节点版本: 8.12
  • 量角器版本: 5.4.2
  • 浏览器: Chrome
  • 操作系统和版本Ubuntu 16.04
  • 量角器配置文件:
'use strict';

require('babel-core/register');

const myReporter = require('./Report/MyReporter');
const Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
const failFast = require('jasmine-fail-fast');

module.exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    framework: 'jasmine2',
    allScriptsTimeout: 600000,
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: ['--test-type', 'no-sandbox'],
        },
    },
    onPrepare: () => {
        browser.manage().window().setSize(1200, 1024);
        jasmine.getEnv().addReporter(failFast.init());
        jasmine.getEnv().addReporter(myReporter);
        jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
            takeScreenshots: true,
            takeScreenshotsOnlyOnFailures: true,
            fixedScreenshotName: false,
            fileNameDateSuffix: true,
            cleanDestination: false,
            savePath: './Report/testReports/'
        }));
    }
};
  • 相关示例测试
fixed bug

最有用的评论

明天我将发布一个新版本。

所有40条评论

我遇到了同样的问题! :(

@sborland我通过更改standalone-response.xml和update-config.json文件以自己的方式解决了这个问题。 但是此链接可以更好地帮助您:
https://stackoverflow.com/a/55836347

@davidzaque谢谢! 这项工作对我有用。

@davidzaque我有同样的问题。 但是我不想在全球范围内安装硒。 我的angularjs应用程序的节点模块中有量角器,而量角器具有自己的依赖关系,其中Web驱动程序被更新为最新的。 如何专门针对量角器而不是全局安装它?

是的,这是一个错误。 这似乎会影响硒服务器的每个版本。

这是webdriver-manager https://github.com/angular/webdriver-manager/issues/370中列出的错误

这是该修复程序/修复程序的讨论: https :

明天我将发布一个新版本。

作为此问题的临时解决方案,您可以在运行webdriver时显式设置独立版本。
--versions.standalone = 3.9.1

在量角器上运行测试用例时,此解决方案无法帮助我。 如何与量角器一起使用此替代方法?

我仅使用我们当前的设置测试了该解决方案。
但是当看官方文档时
http://www.protractortest.org/#/

我会跑

  • webdriver-manager更新--versions.standalone = 3.9.1
  • webdriver-manager开始
  • 量角器conf.js

希望这对您有任何帮助。

我尝试过的@ tomreinartz90 。 Webdriver通过端口4444成功启动,但运行protractor conf.js时出现错误
[15:28:48] I/launcher - Running 1 instances of WebDriver [15:28:48] I/hosted - Using the selenium server at http://localhost:4444/wd/hub [15:28:50] E/launcher - Cannot define class using reflection [15:28:50] E/launcher - WebDriverError: Cannot define class using reflection

@ZehraHN我发现当我使用3.141.0版本时,我不再遇到该问题。 3.8或3.9范围内的任何值都导致我得到反射错误。

是的,现在可以使用。 谢谢@clymerrm

@davidzaque我有同样的问题。 但是我不想在全球范围内安装硒。 我的angularjs应用程序的节点模块中有量角器,而量角器具有自己的依赖关系,其中Web驱动程序被更新为最新的。 如何专门针对量角器而不是全局安装它?

@tejasbhosale我不全局使用量角器。 我更改了文件: node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml
在文件中排除与4.0.0-alpha版本相关的引用:
/node_modules/protractor/node_modules/webdriver-manager/selenium/update-config.json
我做了这个改变:

"standalone": {
        "last": "/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar",
        "all": [
            "/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar"
        ]
    },

之后,我将这些文件保留在node_modules路径之外,因此不会对其进行更新,并将以下脚本添加到package.json中:

"scripts": {
        "preinstall": "node_modules/protractor/node_modules/webdriver-manager/bin/webdriver-manager clean",
        "postinstall": "cp standalone-response.xml ./node_modules/protractor/node_modules/webdriver-manager/selenium/ & cp update-config.json ./node_modules/protractor/node_modules/webdriver-manager/selenium/ & node_modules/protractor/node_modules/webdriver-manager/bin/webdriver-manager update --versions.standalone=3.141.59",
        "start": "webdriver-manager start"
    },

我知道,要解决这个问题需要花费很多精力,但这是我设法在他们发布任何其他解决方案之前解决的方法。

面对与npm install相同的问题,正在下载损坏的jar“ selenium-server-standalone-4.0.0-alpha-1.zip.jar”。

尝试再次安装npm。

它本身在webdriver-manager下没有硒目录!

webdriver-manager下的文件:
总计64
-rw-r--r-- 1根根1205 1985年10月26日gulpfile.js
-rw-r--r-- 1个根目录547 1985年10月26日config.json
-rw-r--r-- 1 root root 2455 1985年10月26日README.md
-rw-r--r-- 1 root root 1078 1985年10月26日许可
-rw-r--r-- 1 root root 2699 1985年10月26日CONTRIBUTING.md
-rw-r--r-- 1根根21636 1985年10月26日CHANGELOG.md
drwxr-xr-x 2根根4096 Apr 25 15:08 bin
drwxr-xr-x 3根根4096 Apr 25 15:08内置
drwxr-xr-x 2根根4096 Apr 25 15:08文档
drwxr-xr-x 5根根4096 Apr 25 15:08 node_modules
-rw-r--r-- 1个根目录3650 Apr 25 15:08 package.json

完成https://github.com/cnishina/webdriver-manager/commit/7dc17ef36e93f71bc63475612e343ffb84efec0f

另外,由于我们以前没有下载Beta版本,因此我们不下载alpha版本。 请更新至webdriver-manager 12.1.2。 如果使用Protractor下载webdriver-manager,只需删除node_modules目录并重新安装或执行npm install -f 。 将此保持可见性。

cnishina / webdriver-manager @ 7dc17ef完成

另外,由于我们以前没有下载Beta版本,因此我们不下载alpha版本。 请更新至webdriver-manager 12.1.2。 如果使用Protractor下载webdriver-manager,只需删除node_modules目录并重新安装或执行npm install -f 。 将此保持可见性。

@cnishina
感谢您对此问题的及时答复。 但是我在詹金斯(Jenkins)的构建仍然失败,并出现相同的错误。 有什么我可以做的吗?

@tejasbhosale您是否在缓存节点模块目录或工作区? 您可以清理Jenkins工作区,然后重试。 我进行了全新安装,并验证了由于https://github.com/angular/protractor/blob/5.4.2/package.json#L29而获得的带有Protractor 5.4.2的[email protected] 您能否将锁定文件设置为12.1.1?

@cnishina感谢您的回复。 我怀疑类似但清除的工作空间对我不起作用。 我将在jenkins配置中进行更多研究。 但是好消息是它对我的本地环境有效,因此一定是詹金斯。 我检查了我项目的pakcage.json是否正在使用此版本
“量角器”:“ ^ 5.2.0”
这样好吗还能得到webdriver 12.1.2吗?

以下提到的解决方案为我工作:

  • 卸载/安装Java
  • 如果安装了较新版本的Java,则设置环境变量

导航 :
第1步:
C:\ Users \\ AppData \ Roaming \ npmnode_modules
删除以下提到的文件夹

  • 量角器
  • webdriver-manager

第2步:
全局重新安装量角器
npm install -g量角器

第三步:
重新运行Webdriver-manager更新

步骤4:
Webdriver-manager启动不会引发任何错误

我有同样的问题。
通过将量角器从5.4.1更新到5.4.2可以解决此问题。 👍
https://github.com/angular/protractor/issues/5224#issuecomment -486873791

您好@cnishina ,我做了“删除node_modules目录,然后重新安装或执行npm install -f”,但没有解决我的问题:参见下面:

├─┬量角器@ 5.4.2
│├──@ types / [email protected]
│├──@ types / [email protected]
│├─┬阻塞代理@ 1.0.1
││└──[email protected]
├─┬展示│ [email protected]
││└─┬[email protected]
││├─┬[email protected]
│││└─┬[email protected]
│││└──[email protected]
││└─┬[email protected]
││└──[email protected]
│├──粉笔@ 1.1.3
│├─┬[email protected]
││├──fs。 [email protected]
││├─┬机上@ 1.0.6
│││├──一次@ 1.4.0
│││└──[email protected]
││├──继承@ 2.0.3
││├─┬[email protected]
│││└──括号展开
││├─┬一次@
│││└──[email protected]重复数据删除
││└──[email protected]重复数据删除
│├─┬茉莉花@
││├──出口@
││├─┬[email protected]
│││├──fs。 [email protected]重复数据删除
│││├──飞行中@ 1.0.6
│││├──继承@ 2.0.3
│││├─┬[email protected]
││││└──括号展开
│││├──一次@ 1.4.0
│││└──[email protected]重复数据删除
││└──茉莉花芯@
│├──[email protected]
│├─┬乐观主义者@ 0.6.1
││├──[email protected]
展示│展示│└── [email protected]
│├──[email protected]
│├─┬[email protected]
││└──[email protected]重复数据删除
├─┬展示│ [email protected]
││├─┬[email protected]
│││├─┬谎言@
││││└──立即@ 3.0.6
│││├──[email protected]
│││├─┬可读流@ 2.3.6
││││├──[email protected]
││││├──继承@ 2.0.3
││││├──[email protected]
展示│展示│展示│展示│├── [email protected]
││││├──安全缓冲
││││├─┬[email protected]
││││││──安全缓冲
││││└──[email protected]
│││└──[email protected]
││├──[email protected]重复数据删除
││├─┬[email protected]
│││└──[email protected]重复数据删除
││└──[email protected]重复数据删除
│├─┬[email protected]
││└──[email protected]重复数据删除
├─┬展示│ [email protected]
││├──@ types / [email protected]重复数据删除
展示│展示│└── [email protected]重复数据删除
└─┬展示│ [email protected]
│├──[email protected]
│├──粉笔@ 1.1.3
│├─┬[email protected]
││├─┬[email protected]
│││├─┬[email protected]
│││││└──[email protected]
│││├──[email protected]
│││├─┬[email protected]
││││├──fs。 [email protected]重复数据删除
││││├──飞行中@ 1.0.6
││││├──继承@ 2.0.3
││││├─┬[email protected]
││││││└──括号展开
││││├──一次@ 1.4.0
│││││──重复数据路径为
│││├──对象分配
│││├──[email protected]重复数据删除
││││└──[email protected]重复数据删除
││├──[email protected]
││├─┬[email protected]
│││└─┬[email protected]
│││└──[email protected]
││├──[email protected]重复数据删除
││├──[email protected]
││├─┬[email protected]
││││pink──[email protected]
││└──[email protected]重复数据删除
│├──[email protected]
│├──[email protected]
│├──[email protected]
│├──[email protected]重复数据删除
│├─┬[email protected]
││├──[email protected]
││├──[email protected]
展示│展示│├── [email protected]
││├─┬合并流@ 1.0.7
│││└──延迟流@ 1.0.0
││├──扩展@
展示│展示│├── [email protected]
││├─┬[email protected]
│││├──[email protected]
│││├──合并流@ 1.0.7重复数据删除
│││└──[email protected]
││├─┬[email protected]
│││├─┬[email protected]
││││├──[email protected]
││││├──[email protected]
││││├──[email protected]
││││└─┬[email protected]
展示│展示│展示│展示│└── [email protected]
│││└──[email protected]
││├─┬[email protected]
│││├──[email protected]
│││├─┬[email protected]
││││├──[email protected]重复数据删除
││││├──[email protected]
││││├──[email protected]
│││││┬─┬[email protected]
││││├──[email protected]重复数据删除
││││├──[email protected]重复数据删除
│││││──[email protected]重复数据删除
│││└─└[email protected]
│││├─┬[email protected]
│││││──安全缓冲
│││├──[email protected]重复数据删除
│││├─┬[email protected]
││││└──[email protected]重复数据删除
│││├─┬破折号@
││││└──[email protected]重复数据删除
│││├─┬[email protected]
││││├──[email protected]重复数据删除
│││││──安全缓冲
│││├─┬[email protected]
││││└──[email protected]重复数据删除
│││├──[email protected]
│││├──安全缓冲
│││└──[email protected]
││├──[email protected]
││├──[email protected]
││├──[email protected]
││├─┬[email protected]
│││└──[email protected]
││├──[email protected]
││├──现在的性能@ 2.1.0
││├──[email protected]
││├──安全缓冲区@ 5.1.2
││├─┬[email protected]
│││├──[email protected]
展示│展示│展示│└── [email protected]
││├─┬[email protected]
│││└──安全缓冲区@ 5.1.2
││└──[email protected]
│├─┬[email protected]
││└─┬[email protected]
││├──fs。 [email protected]重复数据删除
││├──飞行中@ 1.0.6
││├──继承@ 2.0.3
││├─┬[email protected]
│││└──括号展开
││├──一次@ 1.4.0
││└──[email protected]重复数据删除
│├──[email protected]
│└─┬[email protected]
│├──[email protected]
│└──[email protected]

但是,我把我的package.json的依赖项:
“ webdriver-manager”:“ ^ 12.1.2”
并解决了问题。
@cnishina感谢您对此问题的迅速答复。

我有同样的问题。
解决方法是将量角器从5.4.1更新为5.4.2.👍
#5224(评论)

谢谢 !!!!

对于StackOverflow,我试图找到要回答的帖子。 我最终创建了一个问题并回答了这个问题:

https://stackoverflow.com/questions/55869815/error-invalid-or-corrupt-jarfile-node-modules-protractor-node-modules-webdriv

我对webdriver-manager更新正在做什么以及发生的原因有一个简短的解释。 我们可以提高知名度吗?

也许我不明白如何定义版本? 我将package.json更新为包含"protractor": "^5.4.2" ,但是在删除node_modules并重新安装后,我看到node_modules/protractor/package.json具有"webdriver-manager": "^12.0.6" (以及下载zip.jar的问题)。

也许我不明白如何定义版本? 我将package.json更新为包含"protractor": "^5.4.2" ,但是在删除node_modules并重新安装后,我看到node_modules/protractor/package.json具有"webdriver-manager": "^12.0.6" (以及下载zip.jar的问题)。

您是否也在全球范围内安装了量角器?

不,我使用./node_modules/protractor/bin/protractor ,但我发现which protractor没有任何结果。

当您运行webdriver-manager version您也会获得版本12.0.6?

我的意思是对于量角器5.4.2,没有更改package.json,只是webdriver-manager是更新版本

我没有全局安装它。 我记得当我开始这个项目时,我花了一些时间发现量角器中的webdriver需要更新,其中包含./node_modules/protractor/bin/webdriver-manager update 。 当我检查该版本时:

$ ./node_modules/protractor/bin/webdriver-manager version
[16:29:49] I/version - webdriver-manager 12.1.1

所以,这似乎更好吧? 然而,

$ ./node_modules/protractor/bin/webdriver-manager update
[16:31:28] I/file_manager - creating folder /home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium
[16:31:28] I/config_source - curl -o/home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml https://selenium-release.storage.googleapis.com/
[16:31:28] I/config_source - curl -o/home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[16:31:28] I/config_source - curl -o/home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[16:31:29] I/downloader - curl -o/home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.46.zip https://chromedriver.storage.googleapis.com/2.46/chromedriver_linux64.zip
[16:31:29] I/downloader - curl -o/home/man/logicgate/dev/logicgate/platform/client/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-4.0.0-alpha-1.zip.jar https://selenium-release.storage.googleapis.com/4.0/selenium-server-standalone-4.0.0-alpha-1.zip
...

即alpha zip !,导致启动时损坏的jar错误。

因此,您应该是最新的。 最新版本是12.1.4。 以前版本的12无法使用,因为它正在下载的文件已更改。 请查看以上内容以获取升级说明。

我做了升级。 让我尝试再次解释,因为这非常令人困惑:正在使用webdriver-manager两种不同的定义。

我项目中的package.json具有"protractor": "^5.4.2" 。 我从未明确包含过“ webdriver-manager”。 当我运行要更新的命令(即硒包中的内容)时,我运行了./node_modules/protractor/bin/webdriver-manager update -与量角器bin目录中的webdriver构建进行交互。 这很麻烦,并且在我安装了node_modules之后需要进行更新,但是一直有效,直到发生重大变化为止。

"webdriver-manager": "^12.1.4"放在我的package.json中对量角器使用的版本没有影响。 我可以按照以下步骤操作:

  • npm install在我的项目目录中
  • 编辑node_modules/protractor/package.json的文件以将webdriver-manager更新为^ 12.1.4。
  • npm install中的node_modules/protractor/
  • ./node_modules/protractor/bin/webdriver-manager update

证明更新的量角器/ bin / webdriver-manager将获得正确的版本。 但是,我不希望在CI管道中使用“现在编辑安装后量角器package.json”。 有强制强迫量角器使用最新的webdriver-manager的其他方法吗?

您可以更新package.json并将webdriver-manager添加到devDependencies吗? 那为我解决了这个问题。

在上面的实验中,量角器和webdriver-manager(添加时)均处于devDependencies中。

您运行./node_modules/protractor/bin/webdriver-manager update时是否已验证版本为12.1.4? 有两种方法可以做到这一点:

  1. 转到node_modules / protractor / node_modules / webdriver-manager / package.json并检查版本号
  2. 运行node_modules/.bin/webdriver-manager version

    量角器(默认情况下)应下载^ 12.0.4版本,这意味着它应获得12.1.4。 如果仍然得到.zip.jar文件,则表示您有旧版本,需要升级它。

我不建议将其添加到您的devDependencies中。 这就是为什么:

假设如果Protractor升级到版本webdriver-manager @ 13,并且您仍将devDependencies设置为webdriver-manager @ ^ 12。 当您调用./node_modules/protractor/bin/webdriver-manager update ,不能保证您将运行版本12或13。当量角器调用文件时,它将希望使用版本13。如果您的文件是使用12下载的,则这些文件将不存在。当量角器需要它们时。

  • my-project / package.json:devDependencies中的"protractor": "^5.4.2" ,webdriver-manager无处
  • $ rm -rf node_modules
  • npm install
  • cat node_modules/protractor/package.json|grep webdr
    "webdriver-manager": "bin/webdriver-manager"
    "@types/selenium-webdriver": "^3.0.0",
    "selenium-webdriver": "3.6.0",
    "webdriver-js-extender": "2.1.0",
    "webdriver-manager": "^12.0.6"

量角器(默认情况下)应下载^ 12.0.4版本,这意味着它应获得12.1.4。

说得通。 但是:

$  ./node_modules/protractor/bin/webdriver-manager version
`[11:19:58] I/version - webdriver-manager 12.1.1

扑朔迷离。

@mathpunk ,这里是否有一个package-lock.json文件正在播放中,可能已将其锁定到12.1.1?

我们组织中有一个有趣的场景,因为我们有自己的与自动化相关的npm程序包(在内部注册表上),该程序包从SPA和应用程序中提取自动化。 该软件包使用量角器5.4.2,并且不使用package-lock.json文件,因为我们已经看到npm如何消除依赖项的依赖项的一些问题,这些问题困扰了我们的某些路径。 无论如何,在使用package-lock.json文件的SPA和应用程序中安装依赖于量角器的自动化包版本仍会导致使用webdriver-manager 12.1.1。 npm i会将其安装为一等公民,我们不希望这样做,因为12.1.4和12.1.1仍然存在。 npm update --depth 9999 webdriver-manager无法正常工作,它将从12.1.1更新为12.1.4。 缺少在自动化程序包的每个消耗应用程序中手动更改package-lock.json或重新生成文件的新方法,我们不希望这样做,因为它会更新很多我们希望保留在其上的程序包,以防止回归测试工作,我不确定该怎么办。

@cnishina ,感谢您在量角器上所做的所有工作。 您是否支持从5.4.2分支的分支的PR,该分支只会将webdriver-manager更新为12.1.4?

@simonua你破解了! 删除了package-lock.json,删除了node_modules,安装了webdriver-manager 12.1.4。 我不明白为什么在这个生态系统的两个不同地方定义了版本,但是嘿,问题解决了〜

很高兴做到了。 出于好奇,如果您要还原更改并使用您想要的显式版本运行npm i [email protected] ,我怀疑您的状况会很好。 您将获得的好处是您的其他版本保持不变,这限制了回归的曝光。

这里同样的问题

只需从Selenium网站https://selenium-release.storage.googleapis.com/index.html?path=4.0/下载正确的文件
我将jar文件从* .jar更改为* .zip.jar
工作正常

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

codef0rmer picture codef0rmer  ·  3评论

luakri picture luakri  ·  3评论

smarts picture smarts  ·  3评论

psech picture psech  ·  3评论

vishalshivnath picture vishalshivnath  ·  3评论