【问题标题】:Protractor runs locally, but not in Bamboo (Angular could not be found on the page)Protractor 在本地运行,但不在 Bamboo 中(页面上找不到 Angular)
【发布时间】:2015-07-31 10:19:22
【问题描述】:

在进行 e2e 测试一两天后,我有了想要通过 Bamboo 运行的东西。我可以在我自己的本地服务器上运行所有 e2e 测试,但是 Bamboo 失败并显示以下响应,并且当 Chrome 浏览器窗口弹出时,它显示“403 禁止”:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.100.107:54926/wd/hub
Spec started

  Web App

    Sign In Page
      — should redirect to sign in page if not authenticated[39m
        - Failed: Angular could not be found on the page https://localhost/ : retries looking for angular exceeded
        - Failed: Error while waiting for Protractor to sync with the page: "angular could not be found on the window"

这是一个示例测试:

'use strict';

describe('Web App', function() {

  beforeEach(function() {
    browser.get('https://localhost/');
  });

  describe('Sign In Page', function() {
    it('should redirect to sign in page if not authenticated', function() {
      expect(browser.getLocationAbsUrl()).toMatch('/sign_in');
    });
  });
});

这是我认为与我的 protractor-conf.js 文件相关的内容:

exports.config = {
  allScriptsTimeout: 300000,

  baseUrl: 'https://localhost/',

  framework: 'jasmine2',

  specs: [
    'e2e/sign-in.scenarios.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  onPrepare: function() {
    browser.driver.manage().window().maximize();
    var SpecReporter = require('jasmine-spec-reporter');
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true}));
  },

  getPageTimeout: 10000,

  jasmineNodeOpts: {
    showColors: true,
    print: function() {},
    defaultTimeoutInterval: 300000
  }
};

最后,我们在“grunt test”之前运行了一个“npm install”,所以我希望除了 Chrome 之外所有版本都相同?

我负责 Bamboo 的同事能够在 Bamboo 创建的临时目录中重新创建运行。为了弄清楚发生了什么,我将“ng-app”从 head 标签移到了 body 标签,我弄乱了 protractor-conf.js 文件中的 baseUrl,我的同事现在正在使用我的 nginx配置文件(与他的不同)。

我的想法已经不多了,欢迎提出任何建议!

朱莉

【问题讨论】:

  • 把 https 改成 http 有什么不同吗?
  • 很遗憾没有 alecxe,我也试过了。

标签: angularjs protractor bamboo


【解决方案1】:

起初,在 CI 服务器中运行 e2e 测试并不是一个好习惯。 CI 服务器应该只触发可能在另一台机器上运行的量角器测试(在您的网络上或在 AWS 或 Sauce 实验室等云上) - 请参阅 http://angular.github.io/protractor/#/server-setup

使用在您的网络上运行的 Selenium 服务器,您可以使用新地址设置 protractor-conf.js 文件,如下所示:

seleniumAddress: 'http://<seleniumServer_ip>:4444/wd/hub'

我不明白的另一件事是您的 baseUrl。您应该将您的 Web 应用程序部署在另一台服务器中(而不是在您的 CI 服务器中)并在您网络上的任何浏览器中访问它。然后您可以将 Web 应用地址作为参数传递给 Protractor,例如:

protractor protractor-conf.js --baseUrl="http://<webAppIP>"

使用这种架构,您可以在 seleniumServer 上保持登录状态,并观察运行测试时发生的情况。

++ 你可以通过截图来增强结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    相关资源
    最近更新 更多