【问题标题】:How to setup and run angular js protractor test in jenkins?如何在詹金斯中设置和运行角度 js 量角器测试?
【发布时间】:2016-05-23 01:57:05
【问题描述】:

我有以下配置但出现错误

错误

注册功能 Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] 与当前平台 LINUX 不匹配 18:17:05.892 信息 - 驱动程序提供程序 org.openqa.selenium.edge.EdgeDriver 注册被跳过: 注册功能 Capabilities [{platform=WINDOWS, browserName=MicrosoftEdge, version=}] 与当前平台 LINUX 不匹配 18:17:05.896 信息 - 找不到驱动程序类:com.opera.core.systems.OperaDriver 18:17:05.896 信息 - 驱动程序提供程序 com.opera.core.systems.OperaDriver 未注册 18:17:06.187 警告 - 无法启动:SocketListener0@0.0.0.0:4444 线程“main”java.net.BindException 中的异常:Selenium 已经在端口 4444 上运行。或者其他一些服务正在运行。 在 org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:492) 在 org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305) 在 org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245) 在 org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:64) Selenium Standalone 已退出,代码为 1 Selenium 独立服务器开始于 http://10.33.24.128:43448/wd/hub

Jenkins 命令

##运行测试 node_modules/protractor/bin/webdriver-manager 更新 --standalone node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 & 尽管 ! curl http://localhost:4444/wd/hub/status &>/dev/null;做 :;完毕 node_modules/protractor/bin/protractor protractor.conf.js

我的配置文件在下面

exports.config = {
  直接连接:假,

  能力:{
    “浏览器名称”:“铬”
  },
    chromeDriver: './node_modules/protractor/selenium/chromedriver',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  框架:'茉莉花',
  规格:['tests/specs/*-spec.js'],
  茉莉花节点选择:{
    显示颜色:真,
    默认超时间隔:30000
  }
};

【问题讨论】:

  • node_modules/protractor/bin/protractor protractor.conf.js --troubleshoot 得到什么输出?
  • @alecxe 调试 - 使用 --troubleshoot 调试运行 - 量角器版本:3.1.1 调试 - 您的测试基本 url 未定义 [启动器] 进程退出,错误代码为 1

标签: javascript angularjs jenkins protractor


【解决方案1】:

您有一条错误消息:

Selenium 已经在端口 4444 上运行。或者其他一些服务正在运行。

所以你的测试失败了,因为 Selenium 无法设置,因为它需要的端口已经在使用中。

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

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

您可以通过Port Allocator pluginThrottle Concurrent Builds plugin 限制在同一台机器上并行运行的多个构建要使用相同的端口号。

【讨论】:

  • 谢谢。是否必须在slave上安装chrome浏览器或量角器附带的chromedriver有独立实例?
【解决方案2】:

避免直接处理这个并将其委托给像gulp-angular-protractor这样的gulp插件到:

1).启动/停止 selenium 服务器

2).并运行量角器测试

完整示例

Gulpfile.js

/*jshint node: true, camelcase: false*/
/*global require: true*/

'use strict';

var gulp = require('gulp'),
gulpProtractorAngular = require('gulp-angular-protractor');

// Setting up the test task
gulp.task('regression-suite', function(callback) {
    gulp
        .src(['./tests/specs/*spec.js'])
        .pipe(gulpProtractorAngular({
            'configFile': 'protractor.conf.js',
            'debug': false,
            'autoStartStopServer': true
        }))
        .on('error', function(e) {
            console.log(e);
        })
        .on('end', callback);
});

conf.js

和以前一样

命令提示符

C:>gulp regression-suite

詹金斯

添加一个步骤作为执行 windows 命令

gulp regression-suite

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    相关资源
    最近更新 更多