【问题标题】:Protractor Chrome with XVFB on OSX在 OSX 上带有 XVFB 的 Protractor Chrome
【发布时间】:2015-07-27 17:29:55
【问题描述】:

我想在 Bamboo Linux Build Server 上为我的 Angular 应用程序运行 Protractor E2E 测试,使用 XFVB 来运行 Chrome 和 resp。 Chromium 无头,就像在这个要点中一样:https://gist.github.com/nwinkler/f0928740e7ae0e7477dd

但首先我想检查它是否适用于我正在开发的 OSX 机器。

问题:这在 OSX 上是否可行,如果可以,我做错了什么?

在我的 Gruntfile 中有:

grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-protractor-runner');

还有:

protractor: {
        options: {
            configFile: "test/protractor.conf.js",
            keepAlive: false
        },
        run: {}
    },

    shell: {
        xvfb: {
            command: 'Xvfb :50 -ac -screen 0 1600x1200x24',
            options: {
                async: true
            }
        }
    },
    env: {
        xvfb: {
            DISPLAY: ':50'
        }
    }

最后:

grunt.registerTask('protractor-xvfb', [
        'clean:server',
        'wiredep',
        'includeSource',
        'concurrent:server',
        'autoprefixer:server',
        'connect:e2e',
        'shell:xvfb',
        'env:xvfb',
        'protractor:run',
        'shell:xvfb:kill'
    ]);

(不要介意到 shell:xvfb 的任务,它们可以工作)

在我的 protractor.conf.js 中:

exports.config = {
framework: 'jasmine2',
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
seleniumPort: 4444,
chromeDriver: '../node_modules/protractor/selenium/chromedriver',
troubleshoot: false,
basePath: '../',
specs: ['protractor/***/**/*.js'],
baseUrl: 'http://localhost:9000',
capabilities: {
    browserName: 'chrome'
}};

目前的作用是:

  1. 在 localhost:9000 上提供应用程序
  2. 在后台异步启动 xvfb
  3. 在 localhost:4444:wd/hub 上成功启动独立的 Selenium 服务器
  4. 打开 Chrome 窗口并成功运行测试。
  5. 测试完成后立即终止 xfvb 进程。

但我看不到 Selenium 实际连接到 xvfb 帧缓冲区的任何索引。

【问题讨论】:

  • 测试失败了吗?你从量角器/硒看到什么输出?你能在你的机器上使用 Xvfb(即使用正常显示)运行这个 w/o 吗?
  • 对不起,我忘记写了。有一个 Selenium Standalone Server 成功启动,测试在新打开的 Chrome 窗口中成功完成。这是 Macbook Pro Mid 2012 OSX 10.10.2
  • 那我很困惑。你期望看到什么你不是? Xvfb 是一个虚拟帧缓冲区,所以你不应该从那个屏幕上看到任何东西。
  • 我可以看到我的屏幕上打开了一个 Chrome 窗口,并且 Protactor 在应用程序中导航。如果 Selenium 完全由于您描述的原因而成功连接到 xvfb,我不希望会发生这种情况。我期望测试完全没有视觉反馈,没有浏览器窗口,只有命令行上量角器的反馈。还是我错了?

标签: macos selenium gruntjs protractor xvfb


【解决方案1】:

我认为您遇到的问题是described here

基本上,Mac 上的浏览​​器不支持虚拟帧缓冲区。您最好的选择是在 linux 机器上再试一次。我的猜测是这对你有用。

【讨论】:

    猜你喜欢
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 2017-04-27
    • 2019-05-06
    相关资源
    最近更新 更多