【问题标题】:Unable to run protractor using jenkins无法使用詹金斯运行量角器
【发布时间】:2019-05-27 04:36:35
【问题描述】:

我可以使用命令提示符运行量角器。

但是,当我尝试使用 jenkins 运行量角器时,它启动了 selenium 服务器但不执行浏览器,并且由于超时而失败。

除了项目路径之外,我还需要在 jenkins 端进行任何配置吗?

我也尝试过手动安装软件包以确保其更新。

以下是我尝试使用 jenkins 构建/运行量角器时的错误:

> webhis_jasmine@ protractor C:\Users\user1\.jenkins\HISWEBJASMINE
> protractor conf.js

[12:06:44] I/launcher - Running 1 instances of WebDriver
[12:06:44] I/local - Starting selenium standalone server...
[12:06:46] I/local - Selenium standalone server started at http://10.190.40.39:56419/wd/hub
Started
[31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
[31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m[31mF[0m

我尝试仅使用 jenkins 运行 webdriver-manager 更新来检查它并给出以下错误:

C:\Users\user1\.jenkins\HISWEBJASMINE>webdriver-manager update 
'webdriver-manager' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\user1\.jenkins\HISWEBJASMINE>exit 9009 

这里是配置文件:

// conf.js
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {


  capabilities: {
      'browserName': 'chrome'
  },
  specs: ['Patient_positive.js','Visit_positive.js'],
  suites:{
        Smoke: ['ChainLocators.js', 'Dropdown.js'],
            Regression: 'ElementBasics.js',
            Testbed: 'testbed.js',
            PatientPositive: 'Patient_positive.js',
            PatientNegative: 'Patient_negative.js',
            VisitPositive: 'Visit_positive.js',
            VisitNegative: 'Visit_negative.js',
            EpisodeCPOEPositive: 'EpisodeCPOE_positive.js'
    },
  onPrepare:function(){
      browser.driver.manage().window().maximize();
      jasmine.getEnv().addReporter(
                new Jasmine2HtmlReporter({
                  savePath: './test/reports/',
                  screenshotsFolder: 'images',
                  takeScreenshots: true,
                  fixedScreenshotName: true,
                  takeScreenshotsOnlyOnFailures: false,
                  cleanDestination: false,
                  showPassed: true,
                  fileName: 'Test_Report',
                  fileNameSuffix: '',
                  fileNameDateSuffix: true
                })
              );
             },

        jasmineNodeOpts:{
            showColors: true
        }
};

有关系吗?

更新:我将规范剥离为只有 1 个“它”并运行。设法获得成功结果并生成报告,但我看到浏览器没有像使用 cmd 提示符运行时那样启动。

C:\Users\hafizan.abdmulok\.jenkins\HISWEBJASMINE>npm run protractor 

> webhis_jasmine@ protractor C:\Users\hafizan.abdmulok\.jenkins\HISWEBJASMINE
> protractor conf.js

[15:14:40] I/launcher - Running 1 instances of WebDriver
[15:14:40] I/local - Starting selenium standalone server...
[15:14:43] I/local - Selenium standalone server started at http://10.190.40.39:52793/wd/hub
Started
Successfully open patient page
Successfully enter name
Successfully select title
Successfully select gender
Successfully enter date of birth
Successfully select ID type
Successfully enter idno= 850921141112
Successfully select Nationality= Malaysia
Successfully enter mobile no
Successfully enter patient address line 1
Successfully enter patient address line 2
Successfully enter patient address line 3
Successfully enter patient postcode= 57000
Successfully enter patient city= Bukit Jalil
Successfully select patient State= Kuala Lumpur
Successfully select patient State= Malaysia
[32m.[0m


1 spec, 0 failures
Finished in 63.169 seconds

CGM
[15:15:52] I/local - Shutting down selenium standalone server.
[15:15:52] I/launcher - 0 instance(s) of WebDriver still running
[15:15:52] I/launcher - chrome #01 passed
Finished: SUCCESS

【问题讨论】:

  • 运行 webdriver manager 命令,例如:“node_modules\.bin\webdriver-manager update”
  • @SadikAli 我试过运行这个命令node node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0
  • 有效吗?
  • 不,它不工作

标签: jenkins protractor


【解决方案1】:

尝试在您的配置文件中使用directConnect:true 而不是seleniumAddress: 'http://localhost:4444/wd/hub',

在运行测试之前,请执行以下活动

webdriver-manager clean

node node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0

希望对你有帮助

【讨论】:

  • 目前我也没有使用 seleniumAddress: 'localhost:4444/wd/hub'。目前我正在直接从 node_modules 运行量角器。我也尝试对 webdriver-manager 进行清理并重新安装,但从 jenkins 运行时仍然无法正常工作。
  • @hafizan 你能分享你的config文件吗
  • @hafizan 在您的配置中使用directConnect:true 并尝试运行您的测试
  • 我已经输入了我的配置。它显示 [[09:30:55] I/launcher - 运行 1 个 WebDriver 实例 [09:30:55] I/direct - 直接使用 ChromeDriver...] 但在测试机器上,它不会启动任何浏览器,也不会启动执行测试。如果我在命令提示符下手动运行,它可以完美运行。
  • @hafizan 尝试在更新的答案中执行 pre-req 并在尝试使用 directConnect 运行测试时更新带有错误的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多