Protractor本地安装和全局安装表现不同

3
这是一道棘手的问题。我和其他两位开发人员已经连续工作了近24小时。我有一个conf.js文件,在终端中可以导航到该文件并运行protractor conf.js(使用全局安装副本),它可以完美地运行。每次成功测试后,一个绿色点出现一次,大约需要80秒。这里就有点棘手了。
如果我通过执行(项目路径)/node_modules/protractor/bin/protractor conf.js来强制运行本地安装的Protractor,则它会启动,并立即显示几个绿色点,然后抛出无法连接到Angular的错误。这对于与我们的构建集成存在问题,因为Grunt会寻找并使用本地的Protractor副本。
更复杂的是,另外两位开发人员中的一位可以拉取我的repo并在我的conf.js上轻松运行本地protractor安装。它完美地运行了100%。
Error while waiting for Protractor to sync with the page: "window.angular is 
undefined. This could be either because this is a non-angular page or because your 
test involves client-side navigation, which can interfere with Protractor's 
bootstrapping. See http://git.io/v4gXM for details"

我们已经检查了以下所有内容:
  • Both local and global installations of Protractor are the same version, installed with npm.

    Richards-MacBook-Pro:protractor richardpressler$ npm ls protractor
    wear-test-web-framework@0.0.1 
    /path_to_project/wear-test-track0
    └── protractor@3.1.1 
    
    Richards-MacBook-Pro:protractor richardpressler$ npm ls -g protractor
    /usr/local/lib
    └── protractor@3.1.1 
    
  • Selenium is up-to date. We have run both (path to project)/node_modules/protractor/bin/webdriver-manager update as well as webdriver-manager update to update both local and global selenium server installations

  • I've tried firing up Selenium separately and then pointing Protractor to it so that I can see the output and it looks great when I run the conf.js using the global protractor (protractor conf.js), showing several [Executing] statements each followed by a [Done] statement. However, when I run the local protractor binary with (path to project)/node_modules/protractor/bin/protractor conf.js, I see that Protractor was able to connect to the Selenium instance, but didn't do much afterword:

当量角器的输出看起来像这样:

Richards-MacBook-Pro:protractor richardpressler$ ../../node_modules/protractor/bin/protractor conf.js
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
.......................

Selenium服务器只会输出这个信息:
10:35:47.612 INFO - Selenium Server is up and running
10:35:49.479 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome}]])
10:35:49.487 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 34848
Only local connections are allowed.
10:35:50.516 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome}]]
10:35:50.532 INFO - Executing: [set script timeout: 11000])
10:35:50.537 INFO - Done: [set script timeout: 11000]

有没有人在比较全局、命令行版本和项目中本地安装的Protractor版本时遇到类似的不良行为?

谢谢。

1个回答

4
原来所有与Protractor、Grunt、Selenium等相关的依赖项都在“devDependencies”中,所以当我最初运行“npm install”时,它根本没有安装这些软件包的所有子依赖项。如果我将它们移动到package.json中的“dependencies”中,然后重新运行“npm install”,它就可以完美运行了。或者,如果这些依赖项仍在“devDependencies”中,则使用“npm install --dev”也可以正常工作。
有关“dependencies”、“devDependencies”和“peerDependencies”之间差异的更多信息,请参见此处:npm package.json文件中的dependencies、devDependencies和peerDependencies之间的区别是什么?

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接