javascript - 如何在 Jenkins 中设置和运行 Angular JS Protractor 测试?

标签 javascript angularjs jenkins protractor

我有以下配置但出现错误

错误

registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
18:17:05.892 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] does not match the current platform LINUX
18:17:05.896 INFO - Driver class not found: com.opera.core.systems.OperaDriver
18:17:05.896 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
18:17:06.187 WARN - Failed to start: SocketListener0@0.0.0.0:4444
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:492)
    at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:64)
Selenium Standalone has exited with code 1
Selenium standalone server started at http://10.33.24.128:43448/wd/hub

Jenkins 命令

## run testing
node_modules/protractor/bin/webdriver-manager update --standalone
node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &

while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done

node_modules/protractor/bin/protractor protractor.conf.js

我的配置文件如下

exports.config = {
  directConnect: false,

  capabilities: {
    'browserName': 'chrome'
  },
    chromeDriver: './node_modules/protractor/selenium/chromedriver',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine',
  specs: ['tests/specs/*-spec.js'],
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

最佳答案

您收到一条错误消息:

Selenium is already running on port 4444. Or some other service is.

因此您的测试失败,因为无法设置 Selenium,因为它所需的端口已在使用中。

这可能是因为另一个构建在同一台机器上并行运行,或者因为 Selenium 没有被先前的构建停止,或者其他一些服务器正在使用端口 4444。

在开始构建之前,您需要确保此端口是空闲的。

您可以限制在同一台计算机上并行运行的多个构建,这些构建想要使用相同的端口号 Port Allocator pluginThrottle Concurrent Builds plugin .

关于javascript - 如何在 Jenkins 中设置和运行 Angular JS Protractor 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35353768/

相关文章:

javascript - 一旦父节点在 d3 图中折叠,需要将子节点的链接转移到父节点

angularjs - ng-repeat 仅重复唯一值(合并重复项)

javascript - Angularjs禁用过滤器

php - 如何配置 Jenkins 作业以运行单元测试

python - Jenkins 构建期间无法运行 python 脚本

javascript - 如何在没有另一个数组javascript的情况下过滤一个数组

javascript - 如何使用 javascript 正则表达式替换字符串的一部分

javascript - 将 SVG 作为 React 组件导入不适用于 Next.js

json - 在Elasticsearch中,有没有一种方法可以动态构建并传递JSON查询对象?

linux - 启动 Jenkins 服务器的最佳方式是什么