selenium - 使用 Jenkins 设置 Protractor 的持续集成

标签 selenium jenkins continuous-integration protractor

我正在使用 Protractor 编写自动化测试脚本,现在我需要使用 Jenkins 为此设置 CI。

它需要执行的任务是:

  1. 启动 selenium 独立服务器。
  2. 使用conf.js文件开始测试。
  3. 停止 selenium 独立服务器。

有人可以在这方面提供帮助吗?

最佳答案

我创建了一个小的 bash 脚本来执行此操作。

# start selenium
./node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &

# wait until selenium is up
while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done

# run the build
grunt cibuild --force

# stop selenium
curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1

此脚本是从 jenkins 中的自由式项目调用的(构建 > 执行 shell)

enter image description here

然后通过读取 Protractor 测试结果生成测试结果报告。因此,您必须从 Protractor 生成 junit 报告(查看 here ):

onPrepare: function() {
  // The require statement must be down here, since jasmine-reporters
  // needs jasmine to be in the global and protractor does not guarantee
  // this until inside the onPrepare function.
  require('jasmine-reporters');
  jasmine.getEnv().addReporter(
    new jasmine.JUnitXmlReporter('xmloutput', true, true));
},

为了使报告在 jenkins 中可见,我在作业中添加了构建后操作:发布 JUnit 测试结果报告:

enter image description here

关于selenium - 使用 Jenkins 设置 Protractor 的持续集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21338019/

相关文章:

javascript - android 上的酱错误 "Selenium::WebDriver::Error::UnsupportedOperationError: underlying webdriver instance does not support javascript"

jenkins - 如何访问groovy类文件中的全局变量?

android - :app:mergeDebugResources FAILED Error: java. util.concurrent.ExecutionException : com. android.builder.internal.aapt.AaptException

python - 如何使用 travis-ci.org 测试需要键盘输入的项目?

iOS - 与 FaSTLane/Bamboo 的持续集成

Azure devops - 如何对多个 git 存储库使用相同的 yml

javascript - 没有特定子项的 Protractor 过滤器元素

java - selenium中如何使用方法调用内部的各种方法并返回true

selenium - 如何让WebdriverIO在输入框中慢速输入

java - 动态生成声纳 sonar-project.properties